Restore PostgreSQL 10.6 from crash server

Prepare the new machine with the same version PostgreSQL, ( in this case , we use 10.6 , On Slackware machine ).

PostgreSQL session : 
- Install PostgreSQL using this link
- Change version download source into :
- Change version postgresql.SlackBuild ( 10.6 ) , edit line :
- Build  using script :

   # bash postgresql.SlackBuild

- next install with :
# installpkg  /tmp/postgresql-10.6-x86_64-1_SBo.tgz

Data dir restoration

copy the data dir PostgreSQL from the crash machine to new machine
# /var/lib/pgsql/10.6/data/

into the same directory :
# /var/lib/pgsql/10.6/data/

change the ownership into postgres environment
# chown -Rh postgres:postgres  /var/lib/pgsql/10.6/data

run the service postgres : ( please note : suffix "new" on this script because i was already install postgres with different version )
# bash  /etc/rc.d/ start

the service will not running, so we have to check logs :
# tail -f  /var/log/postgresql-10.6

# tail -f /var/lib/pgsql/10.6/data/log/postgresql-Sat.log

Because the service won't start, it's from the log that was a checkpoint record in the transaction log that probably doesn't exist or is corrupted. so we can use :
# su  -  postgres
$ pg_resetwal 10.6/data/

because the transaction log was corrupted,  we will use -f option :

all right then, that was success

and next run the service and check the data.
#  bash  /etc/rc.d/ start
#  su  -  postgres
$  psql 

and the database was safe. next we should check di content of data in each table.

source :

No comments:

Post a Comment