Reconstruire la base secondaire

On fait un snapshot de la base sur Babar

sudo su - postgres
/usr/local/pgsql/bin/psql -h 127.0.0.1 -p 5433 -c "select pg_start_backup('init dumbo')"
cp -pr /var/lib/postgresql/9.0 /var/lib/postgresql/9.0-dumbo
/usr/local/pgsql/bin/psql -h 127.0.0.1 -p 5433 -c "select pg_stop_backup()"

Préparation et export du snapshot sur Babar

sudo su - postgres cd /var/lib/postgresql/9.0-dumbo rm postmaster.pid rm pg_xlog/* echo 'hot_standby = on' » postgresql.conf echo “standby_mode = 'on'” » recovery.conf echo “restore_command = 'cp -i /var/lib/postgresql/babar_wals/%f %p'” » recovery.conf scp -pr /var/lib/postgresql/9.0-dumbo dumbo.postgresql.fr:/var/lib/postgresql/

Sur dumbo, on charge le snapshot et on démarre en mode recovery/standby

sudo /etc/init.d/postgresql-9.0 stop sudo mv /var/lib/postgresql/9.0 /var/lib/postgresql/9.0-orig sudo mv /var/lib/postgresql/9.0-dumbo/ /var/lib/postgresql/9.0 sudo /etc/init.d/postgresql-9.0 start

Il ne reste plus qu'à tester sur Dumbo :

/usr/local/pgsql/bin/psql -h 127.0.0.1 -p 5433 -c “SELECT pg_is_in_recovery();”; pg_is_in_recovery

t (1 row)