Rsync

From I Will Fear No Evil
Jump to navigation Jump to search

Common rsync commands

Copy with all dot-files included

rsync -av  --include='.*' . /opt/nmsApi_backup/

Normal rsync

rsync -arHS <src> <dest>

rsync over ssh with ignore existing

rsync -arHS --ignore-existing -e "ssh -i /home/chubbard/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" chubbard@radio01:/usr/lib/arm-linux-gnueabihf/* .
rsync -arHS --ignore-existing -e "ssh -p 1022 -i /home/chubbard/.ssh/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" chubbard@radio01:/usr/lib/* .

very useful rsync with recovery

Keep trying to rsync files over until all files arrive at the destination (or at least rsync thinks they did). If you have a massive number of files you can add date commands in there to say when it starts and finishes as well... Dont use time, it might give its own exit 0 that would clobber your logic for rsync.

alias rsyncResume='rsync -arHS --partial --progress'
complete=1; while [[ $complete -gt 0 ]]; do rsyncResume <src> <dest> ; $complete=$? ; sleep 30 ; done