41

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.

50

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).

Therefore:

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/
  • 3
    As it says in the man page --dry-run flag is most commonly used in conjunction with the --verbose flag – Benjamin Leinweber Aug 5 '16 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.