master
SneedBot 2023-09-07 12:09:56 +00:00
parent eb049a627c
commit 4dc10e0f99
3 changed files with 18 additions and 14 deletions

1
scripts/p2 100755
View File

@ -0,0 +1 @@
psql "$RECOVERY_DATABASE_URL"

30
scripts/pitr.sh 100755 → 100644
View File

@ -1,17 +1,19 @@
change recovery_target_time in /etc/postgresql/15/main/postgresql.conf like this
recovery_target_time = '2023-08-12 06:07:00'
change recovery_target_time in /var/lib/postgresql/15/new/postgresql.auto.conf like this
recovery_target_time = '2023-09-07 3:18:24'
systemctl stop postgresql@15-main
mv /var/lib/postgresql/15/main/pg_wal /pg_wal
rm -rf /var/lib/postgresql/15/main
mkdir /var/lib/postgresql/15/main
cp -a /database_backup/. /var/lib/postgresql/15/main
chown postgres:postgres /var/lib/postgresql/15/main
chmod 700 /var/lib/postgresql/15/main
rm -rf /var/lib/postgresql/15/main/pg_wal
mv /pg_wal /var/lib/postgresql/15/main/pg_wal
touch /var/lib/postgresql/15/main/recovery.signal
systemctl start postgresql@15-main
systemctl stop postgresql@15-new
rm -r /var/lib/postgresql/15/new
cp -ar /database_backup/. /var/lib/postgresql/15/new
chmod 700 /var/lib/postgresql/15/new
rm -r /var/lib/postgresql/15/new/pg_wal
cp -ar /var/lib/postgresql/15/main/pg_wal/. /var/lib/postgresql/15/new/pg_wal
touch /var/lib/postgresql/15/new/recovery.signal
systemctl start postgresql@15-new
psql "${DATABASE_URL/5432/"5433"}"
wait after recovery is done then:
rm /var/lib/postgresql/15/main/recovery.signal
rm /var/lib/postgresql/15/new/recovery.signal

View File

@ -2,5 +2,6 @@ cd /staging
git pull
. /e
export SITE="staging.rdrama.net"
export DATABASE_URL=RECOVERY_DATABASE_URL
export WORKER_COUNT="1"
gunicorn files.__main__:app -b 0.0.0.0:5002 -t 0