- Server with caprover installed and ready to go
- Postgres database on that server (one-click apps rock!)
- A google cloud storage bucket with versioning enabled
- Create a caprover app.
- Check "Do not expose as web-app"
- Specify the following environment variables in the App Configs tab (example)
BUCKET_PATH
- Thegs://<bucket>/<filename>.tar.zst
path to the GCS bucket where the db backup should be storedGOOGLE_APPLICATION_CREDENTIALS_JSON
- A JSON service account key, that has permission to create/replace objects in above bucket.PGHOST
,PGPORT
,PGUSER
,PGPASSWORD
- Should point to your db
- Add this github repo in the deployment tab, press force deploy
Reference: https://www.postgresql.org/docs/current/continuous-archiving.html
- Exec into a new container that is running the postgres image
- Make sure that
$PGDATA
is empty - Run this script to download the backup and untar it into the $PGDATA directory
gsutil cp gs://<bucket>/<filename>.tar.zst - | tar -I zstd -xvf - -C $PGDATA
pg_ctl -D $PGDATA reload