~linuxgoose/bocpress

ref: 089af2cd13ff5b43219fd79e2cce1ead7df9c25f bocpress/docs/src/database-backup.md -rw-r--r-- 1.1 KiB
089af2cdJordan Robinson add all_tags lists to templates and postmanager functions to get all unique tags for posts and blog setting to show/hide tags in posts list 3 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