You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hetzner-ansible/roles/restore_postgres/files/restore.sh

25 lines
397 B
Bash

#!/bin/bash
#
#
#
STAGE=$1
DATADIR='/var/lib/postgresql/13/main'
DATE=$(date +%F)
PG_USER=postgres
PG_GROUP=postgres
systemctl stop postgresql
mv ${DATADIR} ${DATADIR}_moved
mkdir -p ${DATADIR}
tar -ixzf /home/backupuser/backups/${STAGE}/postgres/${DATE}/basebackup_${DATE}_*.tar.gz -C ${DATADIR}
chmod 0700 ${DATADIR}
chown -R ${PG_USER}:${PG_GROUP} ${DATADIR}
systemctl start postgresql