From "AllStarLink Wiki"
Revision as of 20:35, 17 October 2019 by Bryan (talk | contribs) (Install nessary packages)
Jump to: navigation, search

Server Backups

AllStarLink, Inc uses a per server backup method based on borg.

Installing Borg on Ubuntu 16

the default package that ships with ubuntu 16.04 LTS is borg 1.0 based and we use the latest 1.1 version as it has several security fixes.

Install nessary packages

apt-get install libacl1-dev python3-dev libssl-dev gcc g++ python3-llfuse

install pip

curl -o

Install Borg

pip3 install borgbackup

Test for proper version

root:~# borg -V
borg 1.1.7
which borg

Install the scripts

This will install a new ssh key for root that matches the account and place the program in the /root/ directory.

cd /
tar -xvf /root/borg-root-config.tar 

Edit the borg script

On the Db servers we add a command to dump the database to /var/mysql-backup-current.sql.bz2

Initialize the repo

Copy the export lines to your shell and run then do


The borg/ASL/db-ord needs to be created on the server

ssh -t mkdir -p borg/ASL/db-ord

now we need to init the repo at that location

borg init -e keyfile-blake2 -p -v

export the key

borg key export --paper

Email this output GPG encrypted to the admin team members.

If we lose this key, there is no way to restore the backup. This means if the server dies, we need the paper key record and the passphrase.

Do the first backup


Check that it's succeed

move to cron

mv /root/ /srv/

edit crontab

edit /etc/crontab to run daily at 8am UTC

#borg backup
30 8 * * *      root    /srv/

Reload the crontab file

service cron reload

Mounting and restoring

Borg makes it easy to mount a backup on the server using "borgfs".

If this is done on a different server or during a restore operation on new servers, the key files need to be imported from the paper key. Selected admin users have the paper keys backed up in encrypted email.

For example on a our db-fnt server:

Take the first 5 lines from the /srv/ file and export them on the cli:

export BORG_REMOTE_PATH=/usr/local/bin/borg1/borg1
export HOST=
export BORG_REPO=
export BORG=/usr/local/bin/borg

Note if doing this on a different server, BORG_REPO= must be the server you intend to restore from.

#import the paper key 
borg key import --paper $BORG_REPO
#make a directory to mount the backups on:
mkdir /mnt/backups
#now mount the borg repo
borgfs $BORG_REPO /mnt/backups/

The files will now be in /mnt/backups:

ls  /mnt/backups/

You can now go into any of these directories and restore files as of the date for the respective directory using normal UNIX utilities.