Always Geeky

Knowledge base for various geeky topics
 

+menu-

Using rsync to ensure 2 directories match

rsync -nrhc --progress /home/user/source/docs/ /home/user/destination/docs/

If you think ‘destination’ includes everything in ‘source’, but want to check, the above command will tell you if this is the case. Here are the options broken down:

-n
This is important, it tells rsync to do a dry-run. Without this option, it will actually copy missing files to the destination.
-r
Recursive. Unless you only want to check files directly below the specified directory, you will likely want to use -r.
-h
Human readable. This means you see the size of the folders in Kb, Mb, Gb, or even Tb, rather than pure bytes.
-c
This one is also very important. Without this option, rsync will use the timestamps on each file to determine if they are identical, which can be misleading. This option forces rsync to use a checksum to ensure that if two files exists, they are actually the same file.

This entry was posted in BASH Snipets, Linux and tagged , . Bookmark the permalink.

 

Leave a Reply