-
Notifications
You must be signed in to change notification settings - Fork 189
Database Maintenance
David Humphrey edited this page Apr 12, 2022
·
9 revisions
- Go to Portainer (staging or production) and locate the
pg-backup-cron-job
container - Click the Console button and select
bin/sh
in order to get a shell in the container - Run a backup:
$ /etc/periodic/daily/create-backup
This will create a new dump file in /var/opt/pg_dumps
with the current date and time.
- Go to Portainer (staging or production) and locate the
pg-backup-cron-job
container - Click the Console button and select
bin/sh
in order to get a shell in the container - Run a restore:
ls /var/opt/pg_dumps
# Locate your desired dump file <absolute-path-to-dump-file>
$ ./restore-backup <absolute-path-to-dump-file>
This will attempt to restore the database to the state in the dump file. NOTE: some operations will fail if tables exist or if the schema in the dump file does not match with the schema in the database, or if Postgres can't make it work for some reason.
- Go to Portainer (staging or production)
- Click on the
primary
environment, which has all of our containers. - Click Containers
- Get the current postgres password going to the
supabase-db
container, and inspecting thePOSTGRES_PASSWORD
environment variable. Copy this (you will need it below). - Go back to Containers and click Add Container to add a new container
- Enter a Name:
db-migrations
- Select the
docker.cdot.systems
Registry. NOTE: if you don't see it, add it via the Registries navigation menu on the left. - Enter Image Name:
db-migrations:staging
- Under Advanced Container Settings, click the Network tab, and change the Network from
bridge
to use current default network (e.g.,blue_default
orgreen_default
). - Under Advanced Container Settings, click the Env tab, and add an environment variable,
DATABASE_URL
with a value ofpostgres://postgres:<$POSTGRES_PASSWORD>@db:5432/postgres
, where<$POSTGRES_PASSWORD>
is the current postgres password for thedb
container. - Click the Deploy the container button
- Look at the Logs for the
db-migrations
container that you just created, and make sure it ran correctly. - Go to the Supabase Console (staging or production)
- Once you are happy with what it has done, you can Remove the
db-migrations
container.
Priorities
3.0 Milestone
3.0 Areas of interest by people
3.0 Discussion
Latest Triage meeting:
Older Triage meetings:
-
Add meetings to this list as they happen