Skip to content
David Cook edited this page Nov 12, 2024 · 12 revisions

Database

The Open Food Network installs the db2fog gem.

If you define s3_bucket in your vars file, the deploy playbook will place a default configuration on your server. It uses the same S3 credentials as the file storage. Read it first if you haven't already. Then you need to create an additional bucket. Also read these bucket naming rules.

  • Create another bucket called as defined in s3_bucket but followed by -backups, e.g. ofn-uk-staging-backups.
  • Add another statement to your user's policy for the created bucket.

If you need to, you can change the used S3 credentials later. Log into the OFN app with an admin account and visit Administration/Configuration/Image Settings. You can also run the backups manually:

cd ~/apps/openfoodnetwork/current   # or where you installed the app
bundle exec rake db2fog:backup RAILS_ENV=production

You should see a backup file in your S3 bucket now.

Known errors

pg_dump: [archiver (db)] connection to database "openfoodnetwork" failed: fe_sendauth: no password supplied

Edit config/database.yml and make sure that a password is set for your environment. But it is more likely that you find the host set to 127.0.0.1, which looks fine. But it must be set to localhost to work for backups.

Files

Files should be stored on S3 directly.

Schedule

The S3 backup is scheduled every 4 hours in config/schedule.rb

Backup to local

A one-off backup of the database and files can be downloaded to your computer using:

ansible-playbook --limit=au_staging playbooks/backup.yml

Restore the last backup

A backup can be restored by running the following command

bundle exec rake db2fog:restore

Check the gem's repository for details.

Clone this wiki locally