Skip to content
Snippets Groups Projects
Commit 5de451d9 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

Scripts for maintaining the databases

parent e73e5506
No related merge requests found
Here are various scripts that help backing up the databases and maintaining
them.
Currenty, we have these:
backup-turris::
Backs up the main turris database from db.turris.cz to archive.turris.cz, in
a strongly encrypted form. This should be run from cron.
store-backup::
A forced command for SSH, on the receiving side. This will accept the data
and store it into a file. This is configured with a key in .ssh/authorized_keys.
purge-backups::
This is run on archive.turris.cz, to clean up old database backups.
#!/bin/sh
set -xe
renice -n 10 -p $$
# Use compression externally from pg_dump ‒ xz is better than gz and this can run on separate core
# The xz -5 is a compromise between size and speed. But we may revisit later, when the DB is larger.
(echo turris ; pg_dump -Fc -Z 0 turris | xz -5 | gpg -e -r db@turris.cz) | ssh db-backup@217.31.192.99
#!/bin/sh
set -ex
purge_dir() {
find "$1" -mtime +"$2" -delete
}
purge_dir turris 8
#!/bin/sh
# The first line of the remote command should be the directory to store to
read DIRECTORY
cd "$DIRECTORY"
DATE="$(date +%Y-%m-%d-%H-%M)"
NAME="$DATE".dbdump.xz.gpg
touch "$NAME"
chmod 0600 "$NAME"
cat >"$NAME"
chmod 0400 "$NAME"
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment