RSync

WebHome | UnixGeekTools | Geekfarm | About This Site

Pointers

remote file lists

One little known feature of rsync is the fact that when run over a remote shell (such as rsh or ssh) you can give any shell command as the remote file list. The shell command is expanded by your remote shell before rsync is called. For example, see if you can work out what this does:

    rsync -avR remote:'`find /home -name "*.[ch]"`' /tmp/

osx and rsync

From http://www.macosxhints.com/article.php?story=20031024013757927

About resource forks

rsync, like most UNIX commands, is not aware of resource forks. In my environment, I am considering resources forks as things of the past because most of the current OSX applications that are binary-compatible with PC files (Word, Excel, Photoshop, Acrobat, MP3, MPEG, etc) will accept a file that has lost its resource fork, as long as the proper file extension is present.

There is a version of rsync that is aware of resource-forks, but I am not confident enough with it to use it. Therefore, I have taken the path of asking my users to always include extensions. It is a choice, not the best one, but it is reliable.

panic - rsync not installed

    time tar -cf - rws.vbs | ssh -C server 'cd /path; tar -xBpf -'

Making incremental backups with rsync...

Why I no longer use rsync-based solutions

I prefer Bacula for this task since it is more cross-platform, e.g. it allows me to store resource forks from OS X on my FreeBSD servers.... It is also simple to use and is quite powerful.

My encrypted rsync-based solution to preserve resource forks

I used to use a hand-rolled solution that allowed me to preserve resource forks on FreeBSD that involved:

This has the advantage that only the client can read the data (i.e. if someone compromises the server and steals the image, they can't open it without the password, and the password is never sent directly to the server). Not even Bacula can do this yet...

    # attach to a samba mount
    # note: this directory must be created manually
    /sbin/mount_smbfs -W geektank '//user:passwordhere@hostname/share' /Volumes/mountpoint

    # attach to an encrypted image
    echo -n "passwordhere" | /usr/bin/hdiutil attach /path/to/backup.dmg -readwrite -stdinpass

    # now run your rsync job

    # detach encrypted volume
    /usr/bin/hdiutil detach /Volumes/backup

    # unmount samba mount
    # note: if this directory created manually, it will have to be removed manually
    /sbin/umount /Volumes/wu

Dirvish

Dirvish is a fast, disk based, rotating network backup system.

With dirvish you can maintain a set of complete images of your filesystems with unattended creation and expiration. A dirvish backup vault is like a time machine for your data.

rsyncbackup

roll your own

It's actually very easy to extend rsync to incorporate access to old version as well. All you have to do is create a hard linked copy of the backup tree before you run rsync. Rsync will unlink and recreate any files that have changed, so the old version still exists in the copy of the backup tree. This only uses up extra disk space for a file when it changes, so you end up with a complete backup from every day with very efficient disk usage.

The following is a simple script to do this. You may want to change some of the options, especially on the rsync command.

  cp -l today `/bin/date -I -d yesterday`
  rsync -a --delete fileserver:/home today

Note: use gnu cp (gcp on FreeBSD).

Also look at the option --compare-dest=DIR Though I think the hard link option may be better.




Updated Sun Jul 23, 2006 12:13 PM