... | ... | @@ -940,7 +940,7 @@ information on how to pick a restore procedure. |
|
|
|
|
|
2. Then install the right PostgreSQL version and stop the server:
|
|
|
|
|
|
apt install postgres-9.6
|
|
|
apt install postgres-13
|
|
|
service postgresql stop
|
|
|
|
|
|
Make sure you run the SAME MAJOR VERSION of PostgreSQL than the
|
... | ... | @@ -973,10 +973,10 @@ information on how to pick a restore procedure. |
|
|
`BASE` file in place, as the `postgres` user:
|
|
|
|
|
|
sudo -u postgres -i
|
|
|
mkdir -m 0700 /var/lib/postgresql/9.6/main
|
|
|
mkdir -m 0700 /var/lib/postgresql/13/main
|
|
|
ssh torbackup@$BACKUPSERVER $(hostname) retrieve-file pg $OLDSERVER $BASEFILE \
|
|
|
| sed '0,/^$/d' \
|
|
|
| tar -C /var/lib/postgresql/9.6/main -x -z -f -
|
|
|
| tar -C /var/lib/postgresql/13/main -x -z -f -
|
|
|
|
|
|
Add a `pv` before the `tar` call in the pipeline for a progress bar
|
|
|
with large backups, and replace:
|
... | ... | @@ -988,9 +988,9 @@ information on how to pick a restore procedure. |
|
|
* `$CLUSTERNAME` with the name of the cluster to restore
|
|
|
(e.g. usually `main`)
|
|
|
* `$BASEFILE` with something like
|
|
|
`$CLUSTERNAME.BASE.$BACKUPSERVER-20191004-062226-$OLDSERVER.torproject.org-$CLUSTERNAME-9.6-backup.tar.gz`
|
|
|
`$CLUSTERNAME.BASE.$BACKUPSERVER-20191004-062226-$OLDSERVER.torproject.org-$CLUSTERNAME-13-backup.tar.gz`
|
|
|
or, fully expanded:
|
|
|
`bacula.BASE.bungei.torproject.org-20191010-184205-dictyotum.torproject.org-bacula-9.6-backup.tar.gz`
|
|
|
`bacula.BASE.bungei.torproject.org-20191010-184205-dictyotum.torproject.org-bacula-13-backup.tar.gz`
|
|
|
where the `$CLUSTERNAME` is the non-default `bacula`
|
|
|
|
|
|
The above might hang for a while (yes, maybe even a minute) in the
|
... | ... | @@ -1000,20 +1000,26 @@ information on how to pick a restore procedure. |
|
|
that pipeline is there to skip that header. Example of a
|
|
|
successful restore operated in [#31786][]:
|
|
|
|
|
|
ssh torbackup@bungei.torproject.org bacula-director-01 retrieve-file pg dictyotum bacula.BASE.bungei.torproject.org-20191010-184205-dictyotum.torproject.org-bacula-9.6-backup.tar.gz | pv -s 33G | sed '0,/^$/d' | tar -C /var/lib/postgresql/9.6/main -x -z -f -
|
|
|
ssh torbackup@bungei.torproject.org bacula-director-01 retrieve-file pg dictyotum bacula.BASE.bungei.torproject.org-20191010-184205-dictyotum.torproject.org-bacula-13-backup.tar.gz | pv -s 33G | sed '0,/^$/d' | tar -C /var/lib/postgresql/13/main -x -z -f -
|
|
|
|
|
|
[#31786]: https://bugs.torproject.org/31786
|
|
|
|
|
|
6. Make sure the `pg_wal` directory doesn't contain any files.
|
|
|
|
|
|
rm -rf -- /var/lib/postgresql/13/main/pg_wal/*
|
|
|
|
|
|
Note: this directory was called `pg_wal` in earlier PostgreSQL
|
|
|
versions (e.g. 9.6).
|
|
|
|
|
|
6. Make sure the `pg_xlog` directory doesn't contain any files.
|
|
|
7. Tell the database it is okay to restore from backups:
|
|
|
|
|
|
rm -rf -- /var/lib/postgresql/9.6/main/pg_xlog/*
|
|
|
touch /var/lib/postgresql/13/main/recovery.signal
|
|
|
|
|
|
7. Then you need to create a `recovery.conf` file in
|
|
|
`/var/lib/postgresql/9.6/main` that will tell postgres where to
|
|
|
find the WAL files. At least the `restore_command` need to be
|
|
|
specified. Something like this should work:
|
|
|
7. Then you need to create a
|
|
|
`/etc/postgresql/13/main/conf.d/recovery.conf` file that will
|
|
|
tell postgres where to find the WAL files. At least the
|
|
|
`restore_command` need to be specified. Something like this
|
|
|
should work:
|
|
|
|
|
|
restore_command = '/usr/local/bin/pg-receive-file-from-backup $OLDSERVER $CLUSTERNAME.WAL.%f %p'
|
|
|
|
... | ... | @@ -1496,7 +1502,7 @@ named using the template: |
|
|
|
|
|
... for example:
|
|
|
|
|
|
main.BASE.bungei.torproject.org-20190804-214510-troodi.torproject.org-main-9.6-backup.tar.gz
|
|
|
main.BASE.bungei.torproject.org-20190804-214510-troodi.torproject.org-main-13-backup.tar.gz
|
|
|
|
|
|
All of this works because SSH public keys and postgres credentials are
|
|
|
passed around between servers. That is handled in the Puppet
|
... | ... | |