Chapter 18. Backup Reference

Table of Contents

18.1. Configuration
18.2. Advanced Configuration
18.3. Listing Backup Contents
18.4. Restoring From Backup
18.5. Recovery From Earlier Backups
18.6. Offsite backup storage
18.7. Recovering from offsite backup archive

The Symbiosis system includes a component designed to handle backups, using the flexible backup2l software.

backup2l was selected due to its simplicity and flexibility, which allows it to be used easily. By default the backup software executes once per day and archives the contents of significant directories to a local directory.

18.1. Configuration

backup2l is controlled via configuration file /etc/backup2l.conf, this file is well documented, but in brief it contains three important pieces of information:

  • The local directories to backup (/etc, /srv, etc).
  • The destination to which the backups should be stored (/var/backups/localhost)/
  • The number of backups to keep.

The Bytemark Symbiosis system will replace the static file /etc/backup2.conf with a symbolic link to a generated file, which is produced by concatenating the contents of the /etc/symbiosis/backup.d directory.

18.2. Advanced Configuration

Additionally we’ve configured the backup software to easily execute a number of scripts before and after the backup is performed:

/etc/symbiosis/backup.d/pre-backup.d
Any executable script located in this directory is executed, prior to a backup execution.
/etc/symbiosis/backup.d/post-backup.d
Any executable script located in this directory is executed after a backup has completed.

18.3. Listing Backup Contents

To list the contents of your backup area you need to run backup2l with the "-l" flag:

~# backup2l -l
all.1: /etc/.pwd.lock
all.1: /etc/GeoIP.conf.default
all.1: /etc/X11/Xresources/x11-common
all.1: /etc/X11/Xsession
all.1: /etc/X11/Xsession.d/20x11-common_process-args
all.1: /etc/X11/Xsession.d/30x11-common_xresources
all.1: /etc/X11/Xsession.d/40x11-common_xsessionrc
all.1: /etc/X11/Xsession.d/50x11-common_determine-startup
...

Here you will see the contents of the /etc directory which have been archived.

If you’d like to restrict this view you can apply a regular expression to filter the results. For example we can list the files which match the pattern passwd with this command:

~# backup2l -l passwd
Listing locations...
all.1: /etc/exim4/passwd.client
all.1: /etc/passwd
all.1: /etc/passwd-
all.1: /etc/phpmyadmin/htpasswd.setup
all.1: /etc/pure-ftpd/pureftpd.passwd
...

18.4. Restoring From Backup

To illustrate how this works, an example is used. We’re looking for a backup of the file /etc/passwd.

  1. First log in to your machine over SSH (see Chapter 10, Connecting to your server via SSH) as admin.

  2. To find the available versions of the file, run sudo backup2l -l '/etc/passwd$'. The dollar sign is there to show that you want an exact match of /etc/passwd. The first time you run sudo you will be prompted for the admin password. The following output will be generated by backup2l.

    backup2l v1.4 by Gundolf Kiefer
    
    Active files in <all.1101>: 1
      found in all.1101:       0   (    1 left)
      found in all.11:         1   (    0 left)
    
    Listing locations...
    all.11: /etc/passwd

    This shows the latest available version of the file

  3. To recover it you should run sudo backup2l -r '/etc/passwd$'. The following output will be generated

    backup2l v1.4 by Gundolf Kiefer
    
    Active files in <all.1101>: 1
      found in all.1101:       0   (    1 left)
      found in all.11:         1   (    0 left)
    
    Restoring files...
      all.11.tar.gz: 1 file(s) using 'DRIVER_TAR_GZ'

That has restored the file to etc/passwd in the current directory. It is not recommended to run this program in the / directory, as any existing files will get overwritten.

18.5. Recovery From Earlier Backups

It is also possible to pick which version of a file you wish to restore.

  1. First login to your machine over SSH as admin

  2. Then, to show all available versions of a file, run sudo backup2l -a '/etc/passwd$'. Again, the first time you run sudo you will be prompted for a password. The following output is generated.

    backup2l v1.4 by Gundolf Kiefer
    
    Listing available files...
    all.101   -     1067 06/18/08 13:59:47 0000.0000 0644 /etc/passwd
    all.101   +     1118 06/19/08 11:29:10 0000.0000 0644 /etc/passwd
    all.108   -     1118 06/19/08 11:29:10 0000.0000 0644 /etc/passwd
    all.108   +     1153 08/27/08 10:25:45 0000.0000 0644 /etc/passwd
    all.11    -     1067 06/18/08 13:59:47 0000.0000 0644 /etc/passwd
    all.11    +     1153 08/27/08 10:25:45 0000.0000 0644 /etc/passwd
    all.1     +     1067 06/18/08 13:59:47 0000.0000 0644 /etc/passwd

    Note that the versions are not shown in date order, and that the dates are in the US mm/dd/yy format. In that list the + indicates that the file is new and thus contained in the archive file. A - indicates that the file has been removed (or replaced). Choose which backup you wish to recover from.

  3. To recover the file dated 19th June 2008, you need backup number 101 — remember the + indicates that it is present in that archive. To recover that file, run sudo backup2l -t 101 -r '/etc/passwd$'

    backup2l v1.4 by Gundolf Kiefer
    
    Active files in <all.101>: 1
      found in all.101:        1   (    0 left)
    
    Restoring files...
      all.101.tar.gz: 1 file(s) using 'DRIVER_TAR_GZ'

    Notice the -t 101 argument which specifies which backup we want to restore from.

We have now successfully restored the file to etc/passwd in the current directory. We can check by running ls -la etc/

total 16
drwxr-xr-x  2 root  root  4096 2008-09-09 09:56 .
drwxr-xr-x 14 root  root  4096 2008-09-09 09:51 ..
-rw-r--r--  1 root  root  1118 2008-06-19 11:29 passwd

18.6. Offsite backup storage

The Symbiosis system assumes that it is running upon a host provided by Bytemark, with access to an associated external storage area.

As documented every executable located in the directory /etc/symbiosis/backup.d/post-backup.d is executed at the conclusion of a successful backup.

By default only a single script is included, which attempts to determine the name of the remote backup space associated with your machine and copy the local backup directory of /var/backups to this remote location.

18.7. Recovering from offsite backup archive

TODO The daily offsite backup will protect you - document retrieval, via a script.