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.
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/
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加