Install Rsync
Rsync Installation Instuctions
sudo apt-get install rsync
sudo vi /etc/rsyncd.conf
copy into rsyncd.conf
motd file = /etc/rsyncd.motd
[servername]
path = /home/username comment = This is the path to folder on the server uid = nobody gid = nobody read only = false auth users = username secrets file = /etc/rsyncd.scrt
change username/servername
sudo vi /etc/rsyncd.motd
any message you want
sudo vi /etc/rsyncd.scrt
username:password
sudo vi /etc/default/rsync
RSYNC_ENABLE=true
RSYNC_NICE=’10’
RSYNC_IONICE=’-c3′
sudo /etc/init.d/rsync restart
Rsync Command Example | Explanation
sudo rsync -azv /usr/backup_slice1/ /media/backup_slice1
--dry-run
This tells rsync to not actually do anything. It will just write a log of what it would do to the screen. Once you’ve made sure everything will work as you expect, you have to remove this option, and run the command again to perform the actual backup.
--delete
deletes files that don’t exist on the system being backed up.(Optional)
-a
preserves the date and times, and permissions of the files (same as -rlptgoD)
With this option rsync will do all the following:
Descend recursively into all directories (-r)
copy symlinks as symlinks (-l)
preserve file permissions (-p)
preserve modification times (-t)
preserve groups (-g)
preserve file ownership (-o)
preserve devices as devices (-D)-z
compresses the data
-vv
increases the verbosity of the reporting process
-e
specifies remote shell to use
Rsync Command Examples
sudo rsync -azv --delete-excluded --force /home/username/servername/ -e ssh username@servername.example.com:/home/username
copy to server
sudo rsync -azv --delete-excluded --force -e ssh username@servername.example.com:/home/username/ /home/username/servername
copy from server
Rsync Command Example Using Non-Standard SSH Port
assuming your remote server ssh port has been changed
sudo rsync -azv /home/username/servername/ -e "ssh -p xxxx" username@servername.example.com:/home/username
Rsync Command Example No Password / authorized_keys
sudo rsync -azv -e “ssh -i /home/username/.ssh/id_rsa” username@servername.example.com:/home/username/ /home/username/server_backup_on_local_desktop