Off-site Backup with Backupninja

Goal: Setup a remote machine that will be used for incremental backup of critical parts of the LURK servers.

Requirements
This document assumes you already have:
 * A configure Linux/BSD machine to work as off-site backup
 * A  user created on the off-site backup that will be used specifically by the backup scripts
 * Debian based servers (not sure Backupninja will run otherwise without some slight modifications)
 * All the machines (servers and the backup machine) on a working Tinc VPN
 * Enough space on the off-site backup machine :)

On the Off-site machine
mkdir /data/lurk/douglas /data/lurk/agnesbaxter
 * As  create directories for each server

Installation
Clone Backupninja from https://0xacab.org/riseuplabs/backupninja

cd /usr/src/ && git clone https://0xacab.org/riseuplabs/backupninja cd /usr/src/backupninja

./autogen.sh ./configure make make install

note that by running the above all configurations will be in

/etc/backupninja.conf
Some changes: reportemail = some@where.nice when = everyday at 05:55

MySQL local backups
ninjahelper /var/backups/mysql # adjust if this location does not have much free space
 * As  run the command:
 * create a new backup action
 * mysql database backup
 * path:
 * all the databases to backup.
 * select the debian maintenance user for access
 * compress the sql output file
 * select the action and test/run/review the config
 * leave ninjahelper

PostgreSQL local backups
ninjahelper /var/backups/postgres # adjust if this location does not have much free space
 * As  run the command:
 * create a new backup action
 * postgresql database backup
 * path:
 * backup the whole cluster
 * compress the backups
 * custom
 * select the action and test/run/review the config
 * leave ninjahelper

Borg Backup
This is the action that will not only allow you to select which part of your local filesystem to remotely send and rotate to the off-site backup machine, but it will also make sure the local backups above are sent as well!

apt install borgbackup
 * make sure you have  installed:

ninjahelper
 * As  run:
 * create a new backup action, choose borg
 * choose file to include & exclude, add paths, wildcard accepted
 * configure backup destination:
 * dest_directory
 * dest_host  Adjust to the Tinc IP of the off-site backup machine.
 * dest_user
 * dest_type
 * set up ssh keys and test remote connection
 * enable encryption, choose a nice long passphrase
 * enable pruning, keep  (you can adjust if you will run out of space! Keep in mind this is incremental though, so don't panic)
 * select the action and test/run/review the config
 * check that everything is showing up nicely on the backup server in the destination directory!

Edit/Change the local filesystem path to include/exclude
By default Babckupninja will backup some folder and exclude some others. This can be changed during the initial configuration of the borg action but can also be done later.


 * As root, edit
 * Make changes in the section
 * Optional: run, select the   action and   it to make sure it's being sent to the off-site machine. If you're sure of your changes, you can also wait the next backup to happen to see if it worked.