Commonly used commands for rsync, and for remote backup

Source: Internet
Author: User
Tags rsync

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.