Rsync command
From WikiMLT
Copy a directory
Recursive copy whole directory – the directory source-dir will be copied into the existing target-dir:
rsync -r surce-dir target-dir/
Recursive copy a directory content – the content of the source-dir will be copied as content of the existing target-dir:
rsync -r surce-dir/ target-dir/
Sync a directory with another
rsync -rv --delete --append ./music/ /media/<user>/sd-card
Recursive copy of a directory over SSH
rsync --progress -vrazh <local-source> <ssh-host>:<remote-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 and group owner-ships and timestamps,-z: compress file data,-h: human-readable, output numbers in a human-readable format.
Copy a file from a remote instance over SSH
rsync --progress -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" \
<remote-host>:"/home/<remote-use>/backups/backup-${TODAY}.tgz" "$BACKUP_DIR"
- The
sshoptions are appropriate for automated solutions likecronjobs.
References
- GitHub:
metalevel-tech/simple-backup-solutions/Implement incremental backup with Rsync. - Tecmint.com: 10 Practical Examples of Rsync Command in Linux