guix-data-service/scripts/guix-data-service-backup-database
Christopher Baines 796c129a36 Don't include tablespace assignments in the backup dump
This is a comprimise, as this won't help restoring the backup in situations
you want tablespaces, but I'm currently viewing tablespaces as a deployment
concern, so maybe the right thing to do is exclude them. This approach will at
least keep the same behaviour in terms of restoring the backups locally.

This will fix the small dump creation process on data.guix.gnu.org, which is
currently broken because of the tablespace assignments when trying to restore
the backups.
2020-05-14 20:49:46 +01:00

27 lines
775 B
Bash
Executable file

#!/bin/sh
set -eux
DATABASE_NAME=guix_data_service
DEFAULT_BACKUP_DIRECTORY="/var/lib/guix-data-service/dumps"
BACKUP_DIRECTORY="${GUIX_DATA_SERVICE_BACKUP_DIRECTORY:-$DEFAULT_BACKUP_DIRECTORY}"
DATE="$(date "+%Y-%m-%d")"
FULL_BACKUP_NAME="guix_data_service_full.dump"
TEMPORARY_FILE_NAME="${TMPDIR:-/tmp}/guix_data_service_full-$DATE.dump.tmp"
DESTINATION_FILE_NAME="$BACKUP_DIRECTORY/$DATE/$FULL_BACKUP_NAME"
renice 19 -p $$ || true
ionice -p $$ -c 3 || true
pg_dump --format=custom --compress=9 --serializable-deferrable \
--no-comments \
--no-tablespaces \
--username=guix_data_service \
--file="$TEMPORARY_FILE_NAME" \
"$DATABASE_NAME"
mkdir -p "$BACKUP_DIRECTORY/$DATE"
mv "$TEMPORARY_FILE_NAME" "$DESTINATION_FILE_NAME"