knowledgebase

Paritybit.ca Gemini-based Wiki
git clone https://git.sr.ht/~jbauer/knowledgebase
Log | Files | Refs | README

commit 32e875905d24cbcd01ea7ee64c0df9fe9a59282b
parent 77baadf1fcb53ef0fc71b40c4e0373e52b33a975
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Sun, 14 Nov 2021 02:17:04 -0500

*

Diffstat:
Atarsnap-backups-with-acts.gmi | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+), 0 deletions(-)

diff --git a/tarsnap-backups-with-acts.gmi b/tarsnap-backups-with-acts.gmi @@ -0,0 +1,56 @@ +# 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: + +```acts.conf +#!/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: + +```acts-pre.sh +#!/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" +``` + +```acts-post.sh +#!/bin/sh + +# Only keep db backups less than 7x24h old +find /var/backups/ -type f -mtime +7 -delete +```