How to backup using rsync to local and remote server

How to backup using rsync to local server

rsync -av --delete /source/directory/ /destination/directory/
rsync -av --delete /media/windowsshare/ /home/kim/Downloads/destination/

-v verbose
-h human-readable format
-z is to enable compression
-a archive mode 
(recursive, preserves symbolic links, permissions, timestamsp, owners and groups)

–delete delete any files in /destination/ that are not present in /source/
–stats file-transfer stats
–progress show progress during transfer

I personally like below for showing status

sudo rsync -avh --delete --stats --progress /source/ /destination/

Change the ownership of your destination folder to your liking after completing rsync backup

sudo chown nobody.nogroup /srv/samba/Monday/


How to backup to remote server

sudo rsync -av --delete -e ssh /local/directory/

If your ssh is running on another port (eg 443)

sudo rsync -av --delete -e 'ssh -p 443' /local/Directory/ kim@192.168.x.x:/remote/directory/

Backup using private key instead of password

sudo rsync -avh --delete --stats --progress -e "ssh -i /path/to/private/key" /source/folder kim@hostname:/destination/

Automate your backup with crontab -e

0 23 * * * rsync -av --delete /source/ /destination/


Backup a single large file to remote server

rsync -avz --stats --progress /source/ root@<remote-ip>:/remote/directory/

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top