Tuesday, 22 March 2022

PostgreSQL - Debian Linux Recovery - Database recovery from directory level backups - ODOO 11 recovery from crashed server


 
 
 
  • Debian Linux 
  • PostgreSQL Version 9.6
  • Frontend Application Odoo 11
  • Database recovery from postgresql data directory. 

Problem: Recently Linux Server running Odoo 11 crashed due to power failure. Storage disk seems to be working fine but server was unable to boot OS. GRUB recovery & boot partition recovery was tested but still server was unable to initiate OS at start. Lucky us! directory level backups of Linux OS was taken earlier. 


PostgreSQL Recovery Steps

  • In PostgreSQL 9.6 /var/lib/postgresql/9.6/main is the data directory. This directory is being taken from backups. 
  • Installed fresh Debian 9 including postgresql server. 
  • systemctl stop postgresql 
  • Backed up and moved  default data directory /var/lib/postgresql/9.6/main after fresh installation and pasted the data directory on same location taken from backups. 
  • chown postgres:postgres -R /var/lib/postgresql/
  • chmod 775 -R /var/lib/postgresql/
  • systemctl start postgresql 
  • systemctl status postgresql
  • Also verify postgresql is listening on default port: netstat -antp

 

Take Database dump

su - postgresql

psql -U postgres

 \l #To list databases & note database name

\q

#Take Dump: 
pg_dump database_name > dump.sql

cat dump.sql #to verify dump.sql


ODOO 11 application recovery. 

  • Odoo 11 database backup contains following files. 
  • dump.sql , manifest.json & filestore
  • filestore location in my case: /opt/merp/.local/share/Odoo/database-name/ & default location is: /home/odoo/.local/share/Odoo/Filestore

Combine filestore, dump.sql and manifest.json(this file can be taken from any odoo 11 backup and change database name inside it) into .zip file and restore into odoo 11 fresh installation. 


 

 

 

No comments:

Post a Comment