21.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.

  1. stop apache (BETY/PEcAn web apps) service httpd stop or service apache2 stop
  2. backup database (you know just incase) pg_dump -d bety > baddb.sql
  3. drop database sudo -u postgres psql -c 'drop database bety'
  4. create database sudo -u postgres psql -c 'create database bety with owner bety'
  5. load database (assuming dump is called bety.sql.gz) zcat bety.sql.gz | grep -v search_path | sudo -u postgres psql -d bety
  6. start apache again service httpd start or service 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.