rsync to copy files which has changed

I need to copy some files from a particular directory to a different location on a daily basis. I want to copy the changes only, so planning to use rsync. These files follows the following naming convention mysql-bin.*

My command looks as follows

# rsync --update -raz --progress /var/lib/mysql/mysql-bin.*  /dbdata/binarylog/

My confusion is since I am planning to copy only few files from a directory rather than full directory contents , I have used * to copy only required files.
Just want to know whether my command is correct to achieve the same.

Asked By: Zama Ques


It looks OK. Although why are you using the -z option to compress the transfer? This option is normally used when you are copying to a remote rsync server over a slow network. In this instance it will compress and instantly decompress the files which will only increase your CPU uage with no benefit.

The -a (archive) option implies the -r (recursive) option so there is no need to explicitly specify that on the command line.

You can use the -n option (or --dry-run) to check your command. It will show what it would do without actually copying any files. To actually see what happens you should also use the -v option (or --verbose).


rsync -uanv /var/lib/mysql/mysql-bin.*  /dbdata/binarylog/

and once you’re happy that the files are listed correctly on the dry-run, remove the nv:

rsync -ua --progress /var/lib/mysql/mysql-bin.*  /dbdata/binarylog/
Answered By: garethTheRed
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.