Canonical Voices

Posts tagged with 'backup'

Jussi Pakkanen

Developing with the newest of the new packages is always a bit tricky. Every now and then they break in interesting ways. Sometimes they corrupt the system so much that downgrading becomes impossible. Extreme circumstances may corrupt the system’s package database and so on. Traditionally fixing this has meant reinstalling the entire system, which is unpleasant and time consuming. Fortunately there is now a better way: snapshotting the system with btrfs.

The following guide assumes that you are running btrfs as your root file system. Newest quantal can boot off of btrfs root, but there may be issues, so please read the documentation in the wiki.

The basic concept in snapshotting your system is called a subvolume. It is kind of like a subpartition inside the main btrfs partition. By default Ubuntu’s installer creates a btrfs root partition with two subvolumes called @ and @home. The first one of these is mounted as root and the latter as the home directory.

Suppose you are going to do something really risky, and want to preserve your system. First you mount the raw btrfs partition somewhere:

sudo mkdir /mnt/root
sudo mount /dev/sda1 /mnt/root
cd /mnt/root

Here /dev/sda1 is your root partition. You can mount it like this even though the subvolumes are already mounted. If you do an ls, you see two subdirectories, @ and @home. Snapshotting is simple:

sudo btrfs subvolume snapshot @ @snapshot-XXXX

This takes maybe on second and when the command returns the system is secured. You are now free to trash your system in whatever way you want, though you might want to unmount /mnt/root so you don’t accidentally destroy your snapshots.

Restoring the snapshot is just as simple. Mount /mnt/root again and do:

sudo mv @ @broken
sudo subvolume snapshot @snapshot-XXXX @

If you are sure you don’t need @snapshot-XXX any more, you can just rename it @. You can do this even if you are booted in the system, i.e. are using @ as your current system root fs.

Reboot your machine and your system has been restored to the state it was when running the snapshot command. As an added bonus your home directory does not rollback, but retains all changes made during the trashing, which is what you want most of the time. If you want to rollback home as well, just snapshot it at the same time as the root directory.

You can get rid of useless and broken snapshots with this command:

sudo btrfs subvolume delete @useless-snapshot

You can’t remove subvolumes with rm -r, even if run with sudo.

Read more
John Pugh

Enterprise class tools are making their way into Ubuntu. One such tool for enterprise class backup is Arkeia Network Backup. Arkeia has been a partner of Canonical for some time and recently have completed work to be added to the Ubuntu Partner Repository.

Arkeia has made Arkeia Network Backup version 8 available to Ubuntu users via the Ubuntu 8.04 LTS Partner Repository. Not only did Arkeia make their product available, they made it FREE exclusively to Ubuntu 8.04 LTS users. That is right, you read correctly, FREE.

Arkeia Network Backup, Enterprise Edition for Ubuntu is fully-featured and is not time-limited.   One free, perpetual license is granted per individual or company and only web registration is required.

The enterprise license includes:

  • one backup server running on Ubuntu
  • up to 250GB capacity for backup to disk
  • support of any single drive, tape or disk
  • 2 client agents to backup many types of client machines including Windows workstations and desktops, and the vast majority of Linux machines, Mac OS X and BSD computers

Arkeia Network Backup features an easy-to-use web interface so that backup policy setup and management is a breeze. Arkeia’s backup engine leverages parallelism extensively, making Arkeia Network Backup one of the fastest backup and restore solutions in the market.  Source-side data deduplication will be available in early 2010, making backups and restores faster and easier than ever. More than 150 different applications and platforms are supported with specific packages.

If you are running Ubuntu Server 8.04 LTS and wish to install Arkeia Network Backup, simply run “sudo apt-get install arkeia” to get started.

For more information about Arkeia go to For more information about Arkeia and Ubuntu go to .


Read more


Through the last years I have used various own hacks for backing up my desktop(s). There are dozens of packaged backup solutions in Debian/Ubuntu already, but none of them did quite fit my requirements:

  • KISS! no fancy web UI, storage formats, or millions of plugins and configuration files; backups should just be a normally accessible directory
  • Supports standard backup strategy: daily backups for last week, weekly backups for last month, permanent monthly backups. This must not require my computer to be switched on all the time.
  • Runs as my own user, so that I don’t need to set it up each time I reinstall my box
  • No interactivity; any backup solution that requires me to do anything regularly is doomed to fail.
  • Push-style backup to my server through ssh (or derived, like scp or rsync)
  • Supports per-directory filtering to avoid backing up unnecessary stuff; my upload bandwidth is very small. (e. g. I don’t want to include ~/.cache and in ~/evolution I want to ignore the cache subdir).


I have used rsnapshot as a basis for about a year now. It was originally intended to be used with pull-style, but that does not work for home setups behind a NAT. But it’s easy to use push-style with it (details later). It is by and large a fancy wrapper around good old trusted rsync, which is why I liked it from the start: It by and large just creates a full tree copy of your data for each snapshot, and uses hardlinks to avoid duplicate files. So restoring is easy and robust, you can use any file browser to get to your data.

File selection

If in doubt, backup should include a file rather than exclude it. I value completeness over small storage size, and I just check the volume of a snapshot from time to time to ensure that it doesn’t grow too big (it’s currently in the magnitude of 200 MB, which is small enough for daily deltas to be pushed through a slow DSL uplink without much pain). So my approach is to backup everything in /home/martin except explicitly configured files. For configuring the blacklist I use per-directory .rsync-filter files (which have builtin support by rsync).

Excerpt of my ~/.rsync-filter:

# global ignores
- *.log
- *.cache
- .*.swp
- .swp
- .*.lock
# only direct subdirectories/files
- /.ICEauth*
- /.Trash

(In case you wonder, everything in ubuntu/ is either in the Ubuntu archive or in bzr, so no need to include this.)

Another example is ~/.Private/mozilla/firefox/t3znsw4q.default/.rsync-filter:

- /url*.sqlite*
- /*.bak
- /Cache
- /adblockplus
- /OfflineCache

Please see man rsync, section “FILTER RULES” for the details of the syntax.

Having and maintaining a sensible arrangement of your home directory is by far the most difficult aspect of backup, if you need to be stingy with bandwidth.

rsnapshot configuration

You need a central configuration file ~/.rsnapshotrc. The most important settings are the paths to back up, the destination directory, and the modes (daily/weekly/monthly). In addition I include my crontab into the backup, and add a post-backup action to rsync the backup tree to my server. Backups go to /var/backups/$USER on my systems, which is a different partition than /home (can’t stress that enough; today’s file systems are good, but not infallible).

config_version 1.2
snapshot_root /var/backups/martin
cmd_rsync /usr/bin/rsync

link_dest 1
one_fs 1
lockfile /home/martin/.rsnapshot.lock
rsync_long_args -F –delete –numeric-ids –delete-excluded
cmd_preexec /bin/sh -c ‘crontab -l > ~/.crontab’
cmd_postexec /bin/rm ~/.crontab
cmd_postexec /usr/bin/rsync -e ’ssh -i /home/martin/.ssh/id-backup_rsa’ -aHzvPy –delete /var/backups/martin/

interval daily 7
interval weekly 4
interval monthly 6

backup /home/martin martin-home


The last piece of the puzzle is a script which calls rsnapshot regularly with the desired mode. I wrote a small shell script (which lives in ~/bin/backup) which determines the age of the last daily/weekly/monthly backup, and calls rsnapshot with the correct mode argument. It doesn’t do anything if the last backup was done less than a day ago, so it’s designed to be called very often.

The actual cron job just needs to call it every hour:

$ crontab -l
# m h dom mon dow command
05 * * * * $HOME/bin/backup >/dev/null

And voila, from now on I have e. g. yesterday’s backup on

Read more