Automated and off-site backup with Borg Backup and automysqlbackup should have you covered.

We configure Borg Backup out of the box for MOOSE-managed servers. The benefits of this system are:

  • deduplication
  • compression
  • encryption
  • storage off-site (hosts in Manchester have backups in Geneva, and vice-versa)
  • multiple backups with a pruning schedule

By default borg is set to run every day at the server’s daily cron job time:

  • backup all your configuration files in /etc and retain: 28 days and 12 months
  • backup all your sites and user data in /home and retain: 7 days, 4 weeks, and 6 months
  • backup all email account data in /srv/mail and retain: 7 days, 2 weeks, and 2 months
  • backup MySQL databases and retain: 3 days, 2 weeks, and 1 month

Browsing Backups

  • . /etc/faelix/moose/borgbackup to get the configuration loaded
  • export BORG_PASSPHRASE so you don’t need to type the passphrase
  • borg list $REPOSITORY to show all the backups

For example:

etc-2017-02-17                         Fri, 2017-02-17 04:11:06
home-2017-02-17                        Fri, 2017-02-17 04:11:10
mail-2017-02-17                        Fri, 2017-02-17 04:11:14
mysql-v_testmoo_25d282-dump-2017-02-17 Fri, 2017-02-17 04:19:35

Here we have backups of /etc, /home, /srv/mail, and the v_testmoo_25d282 MySQL database all taken on 2017-02-17 (17th February 2017).

To show information about a specific backup archive, say home-2017-02-17:

  • . /etc/faelix/moose/borgbackup to get the configuration loaded
  • export BORG_PASSPHRASE so you don’t need to type the passphrase
  • borg info $REPOSITORY::home-2017-02-17 will show you the information

In our example:

Name: home-2017-02-17
Fingerprint: 3c01cef01f61b229325a76f58de050ef8b381a14abe2ed4846feb55aec97e243
Hostname: moose.faelix.net
Username: root
Time (start): Fri, 2017-02-17 04:11:21
Time (end):   Fri, 2017-02-17 04:11:21
Command line: /usr/local/bin/borg create --compression none -v --stats borg@borg0.g.faelix.net:/home/borg/moose.faelix.net::home-{now:%Y-%m-%d} /home
Number of files: 6

                       Original size      Compressed size    Deduplicated size
This archive:                7.40 kB              7.74 kB              7.74 kB
All archives:              192.25 MB             90.09 MB             11.01 MB

                       Unique chunks         Total chunks
Chunk index:                    3348                36053

This shows us when the backup was created, what it is a backup of, and how large it is (compressed, and deduplicated).

Making an Extra Backup

Sometimes you want to take an extra backup, either just before or just after a large change. We’ve made this easy with just one command:

  • moose.backup before-upgrade will create backups of everything, giving them names ending YYYY-MM-DD-before-upgrade (where YYYY-MM-DD is the date)

You might want to do a backup after your changes as well, just to give extra peace of mind. You can read more about Borg Backup here

Restoring Data from Backup

  • . /etc/faelix/moose/borgbackup to get the configuration loaded
  • export BORG_PASSPHRASE so you don’t need to type the passphrase
  • borg mount $REPOSITORY /mnt to mount the backups so you can copy files out of previous versions
  • umount /mnt when you’re done