13. Examples of usage

In this chapter I will give a few examples of how you can use rsyncbackup, beyound the most trivial backup scenarios described in the previous chapters.

13.1. Mirroring your iPhoto Library

If you have several computers, and want to have your iPhoto library available and updated on all of them, then mirroring your iPhoto libarary could be a good idea. Remeber, the mirror is also a very good backup. Mirroring means that changes on the client will be discarded every time the mirroring is run.

We start with defining a source, which off course is the iPhoto library:

photos|/Users/andreas/Pictures/iPhoto Library/|true|-a

Then we need to define the destination:

photos-mirror-epla|ssh[key=rsyncbackup]:andreas@epla.mydns.no:/Volumes/Media/iPhoto|traceroute -m 2 epla.mydns.no|

In this example I put the iPhoto mirror on a firewire disk on the remote computer. By doing this, I can access the iPhoto mirror from more than one user on the remote computer, which I find preferable.

Then we need to add the following line in one or more backupsets to mirror our iPhoto library:

photos|photos-mirror-epla|true|--progress

Then, things are ready to be tested:

rsyncbackup -b -s photo-sync -vv

Synchronizing iPhoto Libarary

rsyncbackup already have the capability to not only mirror, but synchronize iPhoto library between computers. I will test this myself, and document it when I know there is no issues related to it.

13.2. Synchronizing folder between two computers

We want to create a directory on our local computer, to be fully synchronized with folders on several remote computers. If you know Apple's iDisk, we will approach a similar solution, but hundres of times faster. First we create a local folder ~/InSync. Then we configure the source:

insync-local|local:/Users/andreas/inSync|true|-tlp

Next up is creating a folder on the server to hold a copy of the folder, and configure the destination:

insync-server|ssh[key=rsyncbackup]:andreas@myserver.mydomain.no:rsync_sync/inSync/|true|-tlp

Since we are syncronizing, both the source and destination work as a source and as a destination, therefore we add the following section in both sources.conf and destinations.conf:

# Syncrhonizing the inSync folder
insync-local|local:/Users/andreas/inSync|true|-tlp
insync-server|ssh[key=rsyncbackup]:andreas@myserver.mydomain.no:rsync_sync/inSync/|true|-tlp

We then add a new backupset for synchronization:

[sync]
insync-local|insync-server|true|-u
insync-server|insync-local|true|-u

We run rsyncbackup to copy the first version of the folder to the server:

rsyncbackup -b -s sync -vv

When this run smooth without errors, and you have fixed all your typos in your configuration files, we want to setup this in a crontab to synchronize in example every 10 minutes. Since synchronization is done very often, and rsync takes a bit CPU, we want to give synchronization process lower priority than other processes on your computer. This can be done with the nice command from the crontab file. The crontab entry could look like this:

*/10 * * * * nice -n 19 rsyncbackup -b -s sync -e notifications@myserver.com

The procude above should be followed for all computers wanting to participate in the synchronization.

Possibility of data loss

When a file is changed on more than one computer in the interval since the last synchronization, the file with the most recent modification timestamp will the conflict, and the older file will be discarded. This means that such a synchronization folder has no intension to replace CVS or other revision control system.

You should do backuping (preferably incremental) of your synchronized folder if it contain important data.

13.3. Synchronizing PithHelmet configuration

PithHelmet is a very cool plugin to Safari, which can be configured to remove unwanted commercial on web sites. After using pithHelmet for a while, you will regularly tweak the configuration to better suit your needs. When having multiple computers, this means alot of work to do the same configuration on all versions. Therefore we will try to let rsyncbackup handle the syncing automaticly.

We locate the single configuration file used by PithHelmet and add a source:

pithhelmetrules-local|local:/Users/andreas/Library/Application Support/PithHelmet/com.apple.Safari/PHRuleSet.ka|true|-t

We create a rsync_sync/pithhelmet directory on the server, and add a destination:

pithhelmetrules-server|ssh[key=rsyncbackup]:andreas@myserver.no:rsync_sync/pithhelmet/PHRuleSet.ka|true|-t

The -t option means to preserve the timestamp on the server, which is crucial to get the synchronization to work.

We now add both the source and desination line to both sources.conf and destinations.conf, with the same argument as in Section 13.2, “Synchronizing folder between two computers”.

Next up is adding a backup set, but we have one problem we need to solve first. PithHelmet only reads configuration file when Safari starts. Therefore, if rsyncbackup updates the local configuration file while Safari is running, and you open the PithHelmet rule editor; then PithHelmet will use the configuration in memory, and save this to disk overwriting the "newer" version sync'ed from another computer. When overwriting the configuration file, the timestamp is updated, and this gived the old configutation a "new" timestamp, and this file will be synchornized back to the other computers, replacing the new version with the old one. To solve this problem we need to never run PithHelmet synchronization while Safari is running. We do that by using a conditional shell code (see Section 10, “Conditional shell code”) and the tool isnotrunning provided with rsyncbackup, in the tools folder. The backup set should look like this:

[sync]
# Synchronizing Pithhelmet...
pithhelmetrules-local|pithhelmetrules-server|true|-u
pithhelmetrules-server|pithhelmetrules-local|isnotrunning Safari.app|-u

The procude above should be followed for all computers wanting to participate in the synchronization.

13.4. Synchronizing Safari bookmarks

Coming soon...

Hint: /Library/Safari/Bookmarks.plist.

13.5. Synchronizing Opera bookmarks

Coming soon...

Hint: Library/Preferences/Opera Preferences/Bookmarks.

13.6. Synchronizing FireFox bookmarks

Coming soon...

Hint: Library/Application Support/Firefox/Profiles/axeeepyy.default/bookmarks.html.

13.7. Backup to iPod connected to arbitrary computer

Coming soon...