Install Rsync on Ubuntu Server


Get a Linode SliceI can highly recommend Linode installations. Easy, fully functional, optimized, ready to go, LAMP stack.


My Rsync installation notes

sudo apt-get install rsync

sudo vi /etc/rsyncd.conf

copy into rsyncd.conf

change username/servername

motd file = /etc/rsyncd.motd

[servername]
path = /home/username
comment = This is the path to folder on the server
uid = username
gid = username
read only = false
auth users = username
secrets file = /etc/rsyncd.scrt

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 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

Linux Directory Rules

rsync -vaz ~/qwerty ~/mydir

CREATES a /qwerty directory under the ~/mydir directory

COPIES the DIRECTORY and CONTENTS of the ~/qwerty directory into this newly created directory

Without a trailing slash / it means “COPY THE DIRECTORY”

rsync -vaz ~/qwerty/ ~/mydir

Does NOT CREATE /qwerty directory

COPIES the CONTENTS of the ~/qwerty directory to the mydir directory

A trailing / on a source name means “copy the CONTENTS of this directory”