rsync
rsync options source destination
-v : verbose
-r : copies data recursively (but don’t preserve timestamps and permission while transferring data
-a : archive mode, archive mode allows copying files recursively and it also preserves symbolic links, file permissions, user & group ownerships and timestamps
-z : compress file data
-h : human-readable, output numbers in a human-readable format
-e : specify a protocol
--progress
rsync -zvh backup.tar /tmp/backups/
rsync -avzh /root/rpmpkgs /tmp/backups/
rsync -avz rpmpkgs/ root@192.168.0.101:/home/
rsync -avzh root@192.168.0.100:/home/tarunika/rpmpkgs /tmp/myrpms
rsync -avzhe ssh root@192.168.0.100:/root/install.log /tmp/
rsync -avzhe ssh backup.tar root@192.168.0.100:/backups/
Add a port :
rsync -avzhe "ssh -p1234" backup.tar root@192.168.0.100:/backups/
These two options allows us to include and exclude files by specifying parameters with these option helps us to specify those files or directories which you want to include in your sync and exclude files and folders with you don’t want to be transferred.
rsync -avzhe ssh --progress /home/rpmpkgs root@192.168.0.100:/root/rpmpkgs
rsync -avze ssh --include 'R*' --exclude '*' root@192.168.0.101:/var/lib/rpm/ /root/rpm
We can use ‘–delete‘ option to delete files that are not there in source directory.
rsync -avz --delete root@192.168.0.100:/var/lib/rpm/ .
rsync --dry-run --remove-source-files -zvh backup.tar /tmp/backups/
Set Bandwidth Limit and Transfer File
rsync --bwlimit=100 -avzhe ssh /var/lib/rpm/ root@192.168.0.100:/root/tmprpm/
Also, by default rsync syncs changed blocks and bytes only, if you want explicitly want to sync whole file then you use ‘-W‘ option with it.
rsync -zvhW backup.tar /tmp/backups/backup.tar
more
https://wiki.archlinux.org/index.php/Rsync
2019-05-04 22:00:04
Comments
Add a Comment