Friday, December 31, 2010

BaculaFS v0.1.7: Batch Mode

Last night I released BaculaFS v0.1.7. I've added two main features:
  1. batch mode: in this mode BaculaFS behaves as a frontend for the bextract utility, and will launch it in order to extract the list of files, specified by BaculaFS' cache prefetch options, to the path pointed to by the mount point parameter
  2. cache prefetch from a list of files
These two features were designed to allow operations like the following:
  1. incremental update of a snapshot on a mounted storage device, in a single command:
    baculafs -o batch_extract,prefetch_diff=/path/to/snapshot,cleanup -o client=client-fd,fileset=client-fileset /path/to/snapshot/
  2. if the destination snapshot is on a remote file system, you can either mount it as a local filesystem (e.g. with sshfs) and then use -o prefetch_diff to prefetch the modified files before copying them with rsync, or generate the file prefetch list with rsync like this:
    # mount a view of the current bacula backup
    baculafs -o client=client-fd,fileset=client-fileset,prefetch_symlinks /path/to/first/mount/point
    # mount another view, this time with prefetch list generated by rsync
    rsync -in --out-format='/%n' -a /path/to/first/mount/point/ /url/or/path/of/remote/snapshot/ | baculafs -o prefetch_list=-,client=client-fd,fileset=client-fileset /path/to/second/mount/point
    # and now copy files for real
    rsync -a /path/to/second/mount/point/ /url/or/path/of/remote/snapshot/
    fusermount -u /path/to/first/mount/point
    fusermount -u /path/to/second/mount/point
Happy New Year!

Friday, December 10, 2010

SSH and DBUS Sessions

Applications that need access to the current D-BUS session bus, require special attention when launched from within an SSH session.

Sometimes it's enough to just set the DISPLAY environment variable to the appropriate X display number (e.g. localhost:0.0, or localhost:10.0 - the default when forwarding X connections over SSH), but it's usually not enough.

These applications need to know the so called D-BUS session bus address. This may be scraped from the environment of applications that are already running, and do have access to the session bus, as the value of DBUS_SESSION_ADDRESS, like this:
export $(strings /proc/*/environ| grep DBUS_SESSION | tail -1)
But there may be several possible values when more than one X session is used, and you'll need to select the right one, maybe by also matching the value of DISPLAY.

There is, however, a somewhat cleaner way to do this. The D-BUS environment variables may be set by running one of the machine generated files under ~/.dbus/session-bus - the files there all have names like 479864458729b195d5497c4bb663c100-10, where the string of hexadecimal digits before the dash is the machine UUID and the number after the dash is the X display number.

Here's how I do it in my ~/.bashrc:
session="$HOME/.dbus/session-bus/$(dbus-uuidgen --get)-$(echo $DISPLAY | sed -e 's/\([^:]*:\)//g' -e 's/\..*$//g')"
if [ -e $session ] ; then
    source $session