42

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.

HalosGhost
  • 4,732
  • 10
  • 33
  • 41
Zama Ques
  • 3,186
  • 12
  • 39
  • 54

1 Answers1

51

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/
garethTheRed
  • 33,289
  • 4
  • 92
  • 101