Browse Docs

๐Ÿ’พ Backup & Sync

Rsync

The classic formula

1rsync -arv --info=progress2 photo backup_photo
  • a = archive โ€” preserves permissions (owner, group), times, symbolic links and devices.
  • r = recursive โ€” copies directories and sub-directories.
  • v = verbose โ€” prints what is being copied.

Examples

1rsync -apvz --stats --update --exclude gsast/olap_cubes --exclude gsast/param   user@server-src:/export/ user@server-dest:/home/
2rsync -av -e ssh root@192.168.1.10:/backup/DUMP/* .
3rsync -azp --stats root@oracle-src:/ec/sw/oracle/client/product/12.2.0.1/network/mesg/ ~/mesg/
4rsync -azp /home/user/mesg/ root@oracle-dest.example.com:/ec/sw/oracle/client/product/12.2.0.1/network/mesg/
5
6ssh root@oracle-dest.example.com "ls -lrt /ec/sw/oracle/client/product/12.2.0.1/network/mesg/"
7ssh root@oracle-dest.example.com "chown oracle:dc_dba /ec/sw/oracle/client/product/12.2.0.1/network/mesg/*"
8
9rsync -aS --delete --rsh /export/home backup-host:/export/save

Propagate deletions to the backup

If you delete files in the source directory, rsync does not propagate the deletion to the backup directory unless you add the --delete option.

If you don’t want to delete the files entirely, you can place them in a separate directory with --backup --backup-dir=:

1rsync -arv photo ~/backup_photo --delete --backup --backup-dir=~/backup_photo/delete

Of course, a remote backup is also possible:

1rsync -arv photo user@backup-server:~/backup_photo --delete

Finally, in case your server isn’t listening on SSH port 22, use the -e option, for example SSH on port 443: -e 'ssh -p 443'.

Sunday, October 4, 2026 Thursday, August 3, 2023