22.3 Restore of BETY database
Hopefully this section will never need to be used. Following are 5 steps that have been used to restore the database. Before you start it is worth it to read up online a bit on restoring the database as well as join the slack channel and ask any of the people there for help.
- stop apache (BETY/PEcAn web apps)
service httpd stop
orservice apache2 stop
- backup database (you know just incase)
pg_dump -d bety > baddb.sql
- drop database
sudo -u postgres psql -c 'drop database bety'
- create database
sudo -u postgres psql -c 'create database bety with owner bety'
- load database (assuming dump is called bety.sql.gz)
zcat bety.sql.gz | grep -v search_path | sudo -u postgres psql -d bety
- start apache again
service httpd start
orservice apache2 start
If during step 5 there is a lot of errors, it is helpful to add -v ON_ERROR_STOP=1
to the end of the command. This will stop the restore at the first error and will help with debugging the issue.