Rsync
Rsync not only transmits fast, but also in the transmission, can compare to copy the content and the local side data difference, if has the difference,
Only the differential data is backed up, and if there is no difference, you do not need to back up
Two ways to work:
1. Run on this machine, as with the CP command; for example: rsync-av/etc/tmp
2. Run between two hosts via SSH, for example: rsync-av-e ssh [email protected]:/etc/tmp
Common commands:
-V: View mode, can list a lot of information
-Q: In contrast to-V, quiet mode, skipping normal information, displaying only the wrong content
-R: Recursive replication. Can be handled on a directory, very important
-U: Update only, if the target file is newer, keeping the new file will not overwrite
-A: Preserves various properties of the original file
Common combinations:
-av
Example: Write a script to backup remote data via SSH, and to automate daily backups with Cron
#ssh-keygen-t RSA
#ssh-copy-id-i/root/.ssh/id_rsa.pub [email protected]
Log in as a key, so you don't need to enter a password for remote backup
#vim back.sh (write backup script)
#!/bin/bash
Localdir=/tmp/backup
Remotedir= "/etc/boot/home"
remoteip= "192.168.50.163"
[-D ${localdir}] | | mkdir ${localdir}
For dir in ${remotedir};d o
rsync-av-e ssh [email protected]${remoteip}:${dir} ${localdir}
Done
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7D/56/wKiom1bmWb7wDxM3AAAnhgoUqhQ920.png "title=") arp$ Uogxt ' 5mug8i0kicqo.png "alt=" Wkiom1bmwb7wdxm3aaanhgouqhq920.png "/>
#chmod +x backup.sh (Add Execute permission to script)
Join the Task Scheduler
#crontab-E
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7D/56/wKiom1bmWjCzTYwLAAAJHeS1H7U979.png "title=" NA (TBF %1brgr9]5r%o0bybd.png "alt=" Wkiom1bmwjcztywlaaajhes1h7u979.png "/>
Test executed successfully
This article is from the "burning Years of Passion" blog, please be sure to keep this source http://liuzhengwei521.blog.51cto.com/4855442/1750865
Commonly used commands for rsync, and for remote backup