...
Stop postgres, if it's running
pg_ctl -D $PGDATA -m smart
Restore the database files from base.tar.gz to $PGRESTORE
gunzip base.tar.gz
tar -xvf base.tar --directory $PGRESTORE
Duplicate the permissions from PGDATA to PGRESTORE, including file owner and file permissions, for example
chmod 700 $PGRESTORE
find $PGRESTORE | xargs chown postgres:daemon
- Copy configuration files from $PGDATA (e.g. $PGDATE/*.conf) to $PGRESTORE.
- (Important!) comment out the following properties from $PGRESTORE/postgresql.conf
- "data_directory"
- "hba_file"
- "ident_file"
- "external_pid_file"
- Add a recovery.conf file to $PGDATA$PGRESTORE. At the very least this should include a 'restore_command' entry (see previous section).
Start postgres
pg_ctl -D $PGRESTORE start
...