💾 Archived View for paritybit.ca › sysadmin › tarsnap-backups-with-acts.gmi captured on 2022-07-16 at 13:42:21. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

Tarsnap Backups With ACTS

ACTS is a POSIX shell script that handles creation and rotation of backups with tarsnap. It requires the tarsnap key is already generated (and it's a good idea to back this key up separately). ACTS can be installed by downloading and un-tarring the latest release found on:

https://github.com/alexjurkiewicz/acts

I generally configure my systems as follows:

#!/bin/sh
# What to back up
backuptargets="var/backups/ <any_other_config_files>"

# How to all tarsnap
tarsnap="nice -n19 tarsnap"

# What arguments to give to tarsnap
# Assumes keyfile and cachefile are set in tarsnap.conf
tarsnapbackupoptions="--one-file-system --humanize-numbers --print-stats"

# How much to log
verbose=1

# Identifies the backup by adding a hostname to the name of the backup
hostname=$(hostname)

# Scripts to run before & after the backup
prebackupscript=/root/acts-pre.sh
postbackupscript=/root/acts-post.sh

# Location of the lockfile
lockfile=/tmp/acts

I run two simple scripts, acts-pre.sh and acts-post.sh, to make dumps of my databases or do other things to get the system to be ready to be backed up. Here is an example of scripts which dump all the postgresql databases and keep the last 7 on disk:

#!/bin/sh

day="$(date +%Y-%m-%d)"
dumpfile="/var/backups/postgres-backup-$day"
touch "$dumpfile"
chown postgres:postgres "$dumpfile"

su -c "pg_dumpall > $dumpfile" postgres

chown 0:0 "$dumpfile"
chmod 600 "$dumpfile"

Note that `su` may have different syntax on other OSes. It may be necessary to run `pg_dumpall -U postgres` without su (optionally with password protection and possibly also a user other than postgres).

#!/bin/sh

# Only keep db backups less than 7x24h old
find /var/backups/ -type f -mtime +7 -delete

Acts should be run regularly. My crontab looks like:

30 04 * * * /root/acts-1.4.2/acts