rsync utility is used to synchronize the files and directories from one location to another in an effective way. Backup location could be on local server or on remote server.
Important features of rsync
- Speed: First time, rsync replicates the whole content between the source and destination directories. Next time, rsync transfers only the changed blocks or bytes to the destination location, which makes the transfer really fast.
- Security: rsync allows encryption of data using ssh protocol during transfer.
- Less Bandwidth: rsync uses compression and decompression of data block by block at the sending and receiving end respectively. So the bandwidth used by rsync will be always less compared to other file transfer protocols.
- Privileges: No special privileges are required to install and execute rsync
Syntax
$ rsync options source destination
$ rsync -zvr /var/opt/installation/inventory/ /root/tempIn the above rsync example:
- -z is to enable compression
- -v verbose
- -r indicates recursive
Example 2. Preserve timestamps during Sync using rsync -a
$ rsync -azv /var/opt/installation/inventory/ /root/temp/
Example 3. Synchronize Only One File
$ rsync -v /var/lib/rpm/Pubkeys /root/temp/
Example 4. Synchronize Files From Local to Remote
$ rsync -avz /root/temp/ thegeekstuff@192.168.200.10:/home/thegeekstuff/temp/
$ rsync -avz thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
Example 7. Do Not Overwrite the Modified Files at the Destination
In a typical sync situation, if a file is modified at the destination, we might not want to overwrite the file with the old file from the source. Use rsync -u option to do exactly that.$rsync -avzu thegeekstuff@192.168.200.10:/var/lib/rpm /root/temp
Example 8. Synchronize only the Directory Tree Structure (not the files)
Use rsync -d option to synchronize only directory tree from source to the destination. The below example, synchronize only directory tree in recursive manner, not the files in the directories.rsync -v -d thegeekstuff@192.168.200.10:/var/lib/ .
No comments:
Post a Comment