Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0
Ce dépôt a été archivé le 2022-05-07. Vous pouvez voir ses fichiers ou le cloner, mais pas ouvrir de ticket ou de demandes d'ajout, ni soumettre de changements.
nyaa-pantsu/deploy/ansible/roles/backup/files/backup.sh

30 lignes
848 o
Bash

# Create a backup from the database
#!/bin/bash
set -eu
NYAAPANTSU_USERNAME="$1"
NYAAPANTSU_PASSWORD="$2"
NYAAPANTSU_DB="$3"
NYAAPANTSU_PASSPHRASE_FILE="$4"
NYAAPANTSU_TRACKER="$5"
NYAAPANTSU_DOWNLOADED_DIR="$6"
NYAAPANTSU_WATCH_DIR="$7"
dump_file="${NYAAPANTSU_DB}_$(date +'%Y_%m_%d_%H_%M').backup"
pg_dump -U "${NYAAPANTSU_USERNAME}" -f "${dump_file}"
xz -z "${dump_file}"
compressed_dump_file="${dump_file}.xz"
signature_file="${compressed_dump_file}.sig"
gpg2 --batch --yes --passphrase-fd 0 \
--output "${signature_file}" \
--detach-sig "${compressed_dump_file}" < "${NYAAPANTSU_PASSPHRASE_FILE}"
mktorrent -a "${NYAAPANTSU_TRACKER}" "${compressed_dump_file}" "${signature_file}"
mv "${compressed_dump_file}" "${signature_file}" "${NYAAPANTSU_DOWNLOADED_DIR}"
mv "${compressed_dump_file}.torrent" "${NYAAPANTSU_WATCH_DIR}/"