rsync is often used to copy files instead of gcp
, but it can also be used to verify a copy, however it was made. Simply do
rsync -niaHc /origfolder/ /copyfolder
Be careful to end the first folder name (the source) with a /
.
The options are
-n
do not copy (make no changes)
-i
itemise the differences
-a
preserve (i.e. compare since we have -n
) permissions, ownerships, symbolic links, etc. and recurse down directories
-H
preserve hard links
-c
compare checksums
The output shows a code detailing the differences for each file or directory that differs. There is no output if they are the same. The code has columns YXcstpoguax
where each character is a dot .
if that aspect of the comparison is ok, or a letter:
Y is type of update:
< sent (not appropriate in this case)
> need to copy
c missing file or directory
h is hard link
. no update
* and rest of line is a message, eg *deleting
X file type: f file d dir L symlink D device S special file
c checksum differs. + new item " " same
s size differs
t timestamp differs
p permissions differ
o owner differ
g group differ
u (not used)
a acl differ
x extended attributes differ
For example,
.d..t...... a/b/ directory timestamp differs
cL+++++++++ a/b/d -> /nosuch2 symbolic link missing
cS+++++++++ a/b/f special file missing (a/b/f is a fifo)
>f..t...... a/b/ff file timestamp differs
hf a/b/xx1 => a/b/xx files should be a hard linked
cLc.t...... a/b/z -> /tmp/hi2 symbolic link to different name
cd+++++++++ a/c/ directory missing
>f+++++++++ a/c/i.10 missing file needs to be copied
See man rsync
under --itemize-changes
for more details. If you have differences in the 3rd c
or 4th s
columns, then you have serious data corruption. Other flags such as different permissions, owner or timestamps may be less important to you. If all the files are marked as "missing" then you have probably not given the right directories to compare. If you are sure, running rsync without the -n
flag will "fix" the differences.
find /origfolder ! -type f ! -type d -ls
. There should be no output.find /origfolder -type f -links +1 -ls
. This is unlikely if the files are your own, and not from some downloaded software package, for example).