alcatrazbr of Linux
6/21/2017 - 1:55 PM

rsync, backup fonte:

#Basic syntax of rsync command
rsync options source destination

#Some common options used with rsync commands
#-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
#--progress : show progress
#--remove-source-files : delete source files after transfer

#Copy/Sync a File on a Local Computer
rsync -zvh backup.tar /tmp/backups/
#Copy/Sync a Directory on Local Computer
rsync -avzh /root/rpmpkgs /tmp/backups/
#Copy a Directory from Local Server to a Remote Server
rsync -avz rpmpkgs/ root@
#Copy/Sync a Remote Directory to a Local Machine
rsync -avzh root@ /tmp/myrpms
#Copy a File from a Remote Server to a Local Server with SSH
rsync -avzhe ssh root@ /tmp/
#Copy a File from a Local Server to a Remote Server with SSH
rsync -avzhe ssh backup.tar root@
#Show Progress While Transferring Data with rsync
rsync -avzhe ssh --progress /home/rpmpkgs root@
# Use of –include and –exclude Options
rsync -avze ssh --include 'R*' --exclude '*' root@ /root/rpm
#Use of –delete Option
#We can use ‘–delete‘ option to delete files that are not there in source directory.
rsync -avz --delete root@ .
# Set the Max Size of Files to be Transferred
rsync -avzhe ssh --max-size='200k' /var/lib/rpm/ root@
# Automatically Delete source Files after successful Transfer
rsync --remove-source-files -zvh backup.tar /tmp/backups/
#Do a Dry Run with rsync
#If you are a newbie and using rsync and don’t know what exactly your 
#command going do. Rsync could really mess up the things in your destination folder and then doing an undo can be a tedious job.
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@

### # ###
#usando o sshpass
sshpass -p 'alca' rsync --progress -avz -e ssh alcatraz@ /mnt/backup/elaine-pc/.