Differences between revisions 4 and 5
Revision 4 as of 2019-07-10 18:02:12
Size: 2971
Editor: DavidAdam
Comment:
Revision 5 as of 2022-06-22 11:47:51
Size: 3866
Editor: NickBannon
Comment: logs, manpage link, need for snapshots/database dumps
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Traditionally, the UCC's backup system has left much to be desired, such as "existing" or "running on reliable hardware". Traditionally, the UCC's backup system has left much to be desired, such as "existing" or "running on reliable hardware", let alone living up to the [[https://www.lawtechnologytoday.org/2014/12/backups-rule-three/|Rule of Three]].
Line 13: Line 13:
On the backup server (mollitz):
 * Copy `/backups/conf/default` to `/backups/conf/<HOSTNAME>.conf`
 * Edit `/backups/conf/<HOSTNAME>.conf` as required - the syntax is documented in [[http://manpages.ubuntu.com/manpages/oneiric/en/man1/rdiff-backup.1.html|rdiff-backup(1)]] under FILE SELECTION
On the backup server (`mollitz`):
 * Copy `/backups/conf/example-copy-me` to `/backups/conf/<HOSTNAME>.conf`
 * Edit `/backups/conf/<HOSTNAME>.conf` as required - the syntax is documented in [[http://manpages.ubuntu.com/manpages/bionic/en/man1/rdiff-backup.1.html|rdiff-backup(1)]] under FILE SELECTION
Line 18: Line 18:
Now wait until the nightly backup run. The output is sent to hostmasters. Now wait until the nightly backup run. The output is:

  * sent by email to hostmasters
  * successful backups leave a log in `/backups/<HOSTNAME>/rdiff-backup-data/backup.log` and `/backups/<HOSTNAME>/rdiff-backup-data/session_statistics.<TIMESTAMP>.data`
  * partially successful backups leave a log in `/backups/<HOSTNAME>/rdiff-backup-data/error_log.<TIMESTAMP>.data.gz`
    * /!\ In some cases, e.g. if a particular file constantly changes during each and every backup run, a successful backup or update may never be possible
    * TODO: this could be mitigated by backing up a stable snapshot, instead of the live filesystem
Line 22: Line 28:
To list all the backups available for a particular host, on the backup server (Mollitz):
 * Run `rdiff-backup --list-increments /backups/<HOSTNAME>`
To list all the backups available for a particular host, or to see when it was last successful, on the backup server (Mollitz) run:
 * `rdiff-backup --list-increments /backups/<HOSTNAME>`

To list how much data is taken for each incremental backup (which is much slower), on the backup server (Mollitz) run:
 * `rdiff-backup --list-increment-sizes /backups/<HOSTNAME>`
Line 28: Line 37:
 * Run `rdiff-backup --list-increments /backups/<HOSTNAME>` and choose a backup to restore from.
 * Copy the timestamp from the increment list - `2013-02-22T02:00:03+08:00`
 * Decide where you are going to restore the files - locally (i.e. to Mollitz), where you can inspect them, or back to the remote host.
 * Run `rdiff-backup --list-increments /backups/<HOSTNAME>` and choose a backup to restore from
 * Copy the timestamp from the increment list - `2022-02-22T02:00:03+08:00`
 * Decide where you are going to restore the files - locally (i.e. to Mollitz), where you can inspect them, or back to the remote host
Line 33: Line 42:
 * Run `mkdir /backups/restored/<HOSTNAME>`
 * Run `rdiff-backup --restore <TIMESTAMP> /backups/<HOSTNAME>/path/to/file-or-directory/you/want/to/restore /backups/restore/<HOSTNAME>`
For example, using `rdiff-backup -r 2013-02-22T02:00:03+08:00 /backups/merlo/etc /backups/restored/merlo` will restore the contents of merlo's `/etc/` directory as at 22/2/13 to `/backups/restored/merlo`.
 * Run `mkdir /backups/tmp/<HOSTNAME>`
 * Run `rdiff-backup --restore <TIMESTAMP> /backups/<HOSTNAME>/path/to/file-or-directory/you/want/to/restore /backups/tmp/<HOSTNAME>`
For example, using `rdiff-backup -r 2022-02-22T02:00:03+08:00 /backups/merlo/etc /backups/tmp/merlo` will restore the contents of merlo's `/etc/` directory as of 22nd February to `/backups/tmp/merlo`.
Line 40: Line 49:
For example, `rdiff-backup -r 2013-02-22T02:00:03+08:00 /backups/merlo/etc merlo::/restored/etc` will restore the contents of merlo's `/etc/` directory as at 22/2/13 to `/restored/etc` on Merlo. For example, `rdiff-backup -r 2022-02-22T02:00:03+08:00 /backups/merlo/etc merlo::/restored/etc` will restore the contents of merlo's `/etc/` directory as of 22nd February to `/restored/etc` on Merlo.

Traditionally, the UCC's backup system has left much to be desired, such as "existing" or "running on reliable hardware", let alone living up to the Rule of Three.

Backups at present run on Mollitz, which is housed in another location (off-site backups!). Contact <[email protected]> if you need to know where it is living.

Backups are run using rdiff-backup, a disk-based incremental backup system. These are managed by rdiff-manager, a Python wrapper written by DavidAdam.

Adding new machines

On the target system (the machine you want to back up):

  • Make sure the UCC backup key is installed (e.g. with authroot)
  • Install rdiff-backup packages.

On the backup server (mollitz):

  • Copy /backups/conf/example-copy-me to /backups/conf/<HOSTNAME>.conf

  • Edit /backups/conf/<HOSTNAME>.conf as required - the syntax is documented in rdiff-backup(1) under FILE SELECTION

  • Add the SSH host key using su -c 'ssh-keyscan HOSTNAME >> ~/.ssh/known_hosts' backups

Now wait until the nightly backup run. The output is:

  • sent by email to hostmasters
  • successful backups leave a log in /backups/<HOSTNAME>/rdiff-backup-data/backup.log and /backups/<HOSTNAME>/rdiff-backup-data/session_statistics.<TIMESTAMP>.data

  • partially successful backups leave a log in /backups/<HOSTNAME>/rdiff-backup-data/error_log.<TIMESTAMP>.data.gz

    • /!\ In some cases, e.g. if a particular file constantly changes during each and every backup run, a successful backup or update may never be possible

    • TODO: this could be mitigated by backing up a stable snapshot, instead of the live filesystem

Checking backup status

To list all the backups available for a particular host, or to see when it was last successful, on the backup server (Mollitz) run:

  • rdiff-backup --list-increments /backups/<HOSTNAME>

To list how much data is taken for each incremental backup (which is much slower), on the backup server (Mollitz) run:

  • rdiff-backup --list-increment-sizes /backups/<HOSTNAME>

Restoring a backup

To restore files from backup, on the backup server (Mollitz):

  • Run rdiff-backup --list-increments /backups/<HOSTNAME> and choose a backup to restore from

  • Copy the timestamp from the increment list - 2022-02-22T02:00:03+08:00

  • Decide where you are going to restore the files - locally (i.e. to Mollitz), where you can inspect them, or back to the remote host

Restoring files locally

  • Run mkdir /backups/tmp/<HOSTNAME>

  • Run rdiff-backup --restore <TIMESTAMP> /backups/<HOSTNAME>/path/to/file-or-directory/you/want/to/restore /backups/tmp/<HOSTNAME>

For example, using rdiff-backup -r  2022-02-22T02:00:03+08:00 /backups/merlo/etc /backups/tmp/merlo will restore the contents of merlo's /etc/ directory as of 22nd February to /backups/tmp/merlo.

Restoring files remotely

/!\ Be careful - this is easy to mess up, particularly if you are trying to restore to the original path. Note the double-colons in the restore path!

  • Run rdiff-backup --restore <TIMESTAMP> /backups/<HOSTNAME>/path/to/file-or-directory/you/want/to/restore root@<HOSTNAME>::/path/to/file-or-directory/you/want/to/restore

For example, rdiff-backup -r  2022-02-22T02:00:03+08:00 /backups/merlo/etc merlo::/restored/etc will restore the contents of merlo's /etc/ directory as of 22nd February to /restored/etc on Merlo.

Improvements to rdiff-manager

rdiff-manager is pretty simple but there is plenty of room for improvement. Check the TODO file in the distribution for ideas.


CategorySystemAdministration