Once upon a time Doug MacFarlane said... > > I will shortly need to copy about 100 gb of data from one filesystem to > another. [...] > > Any suggestions? Just exactly how would one tar one filesystem to another, > without the intermediate tar file? I've done it using cpio(1), since tar didn't like the unix domain sockets in /var/spool/postfix/private. I've attached the script I now use to copy all my filesystems or trees around the place. The script does not cross filesystem boundaries, but it is easily modified to do that. > Also, once the copy is complete, I'd love a tool that would compare the two > filesystems, including crc or md5 checksums on each file, to make sure that > they are, in fact, identical. Can't help here, sorry.
#!/bin/bash
if [ $# -ne 2 ] ; then
echo "Usage: $0 <source_dir> <dest_dir>" >&2
echo "eg: \"$0 /var /mnt\" will create /mnt/var"
echo "eg: \"$0 /var/spool /mnt\" will create /mnt/spool"
echo "eg: \"$0 /var/spool /mnt/var\" will create /mnt/var/spool"
echo "eg: \"$0 / /mnt\" will copy the root fs to /mnt"
exit 1
fi
if [ \! -d "$2" ] ; then
echo "$2 is not a directory" >&2
exit 2
fi
dir_source=$(dirname "$1")
base_source=$(basename "$1")
(
cd "$dir_source"
find "$base_source" -xdev \! -name lost+found |
cpio --create \
--reset-access-time \
--quiet \
--format=newc
) | (
cd "$2"
cpio --extract \
--preserve-modification-time \
--no-absolute-filenames \
--quiet
)