Using Rsync

syncing, backuping

rsync makes easy to make incremental backups : it synchronise files from two different folders and only transferts what have changed.

rsync over ssh

In daily work, it is good to have 2 versions of my work synchronised :

  • one is on my local machine as work version
  • one is on a distant server as test version

Those versions have to be synchronised

rsync -a -c -z -l -e ssh --delete --stats --progress --exclude-from 'rsync_exclude.txt' "spip/" ""



rsync for backup

let's make my backups

  • using TimeMachine is a good option under Mac OS 10.5 : it keeps tracks of each version, see at the bonjour tutorial for setting it up with an ubuntu server
  • some alternative could be to use rsync

rsync to get interrupted ssh connection

When my scp connexion is interrupted, rsync –partial makes the trick

nyx:~ gaspard$ scp -C . s password: 
wp_db.gz         49%  738MB   0.0KB/s - stalled -Read from remote host Connection reset by peer
lost connection
nyx:~ gaspard$ rsync --partial . s password: 

rsync to backup my server

Where are important data on my server ?

path user description
/etc/apache2/ root apache configuration
/home/freelancis/ freelancis hosted websites
/home/mysql/ mysql mysql databases

I want the exact copy of these elements.

backuping /etc/apache2/

I gonna have to use root shell, I hate to do this but it looks like it is the only way.

backuping /home/freelancis/

rsync -a -c -z -e ssh --delete --stats --progress --exclude-from 'rsync_exclude_user_freelancis.txt' "" "user_freelancis"

I just don't need the cached elements, that's why I discard them by using a rsync_exclude_user_freelancis.txt file



There is no shell user as mysql, so i gonna have to use root.

rsync command lines

  • -v, –verbose increase verbosity
  • -q, –quiet decrease verbosity
  • -c, –checksum always checksum
  • -a, –archive archive mode. It is a quick way of saying you want recursion and want to preserve everything.
  • -r, –recursive recurse into directories
  • -R, –relative use relative path names
  • -u, –update don't overwrite files that are newer on the destination directory
  • -t, –times preserve times
  • -n, –dry-run show what would have been transferred
  • -W, –whole-file copy whole files, no incremental checks
  • -I, –ignore-times Normally rsync will skip any files that are already the same length and have the same time-stamp. This option turns off this behavior.
  • –existing only update files that already exist
  • –delete delete files that don't exist on the sending side
  • –delete-after delete after transferring, not before
  • –force force deletion of directories even if not empty
  • -c, –checksum always checksum
  • –size-only only use file size when determining if a file should be transferred
  • –progress show progress during transfer
  • -z, –compress compress file data
  • –exclude=PATTERN exclude files matching PATTERN
  • –daemon run as a rsync daemon
  • –password-file=FILE get password from FILE

more ressources

ressources/ssh/rsync.txt · Last modified: 2013/06/16 22:51 (external edit)
Creative Commons License Powered by PHP Valid XHTML 1.0 April