~linuxgoose/bocpress

ref: 998269312d17fad056e8960a12a1a33f49aeff70 bocpress/docs/src/database-backup.md -rw-r--r-- 1.1 KiB
99826931Jordan Robinson update post detail page for tag query param on url 2 months ago

#Database Backup

#Shell Script

We use the script backup-database.sh to dump the database and upload it into an S3-compatible object storage cloud using rclone. This script needs the database password as an environment variable. The key must be PGPASSWORD. The variable can live in .envrc as such:

export PGPASSWORD=db-password

#Commands

To create a database dump run:

pg_dump -Fc --no-acl mataroa -h localhost -U mataroa -f /home/deploy/mataroa.dump -W

To restore a database dump run:

pg_restore --disable-triggers -j 4 -v -h localhost -cO --if-exists -d mataroa -U mataroa -W mataroa.dump

#Initialise and configure backup script

cp /var/www/mataroa/backup-database.sh /home/deploy/

#Setup rclone

  1. Create bucket on Scaleway or any other S3-compatible object storage.
  2. Find bucket URL.
    • On Scaleway: it's on Bucket Settings.
  3. Acquire IAM Access Key ID and Secret Key.
    • On Scaleway: IAM -> Applications -> Project default -> API Keys
rclone config