GitHub user fightingtexasaggie edited a comment on the discussion: Add a backup
/ restore procedure in the documentation
I put together a simple backup script that uses pg_dump to back up the database
created by the superset docker-compose.yml (actually
docker-compose-image-tag.yml) file.
You'll need a bind mount to get scripts in and data out of your container, so I
added a bind mount in the volume definition of the db. If you're running
traditional root docker, you'll need to chown this directory root:root or
otherwise allow access via a facl.
```
db:
... stuff ...
volumes:
- db_home:/var/lib/postgresql/data
- ./docker/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- type: bind
source: /home/superset/superset_backup
target: /superset_backup
```
I then created a quick and dirty backup script in my host backup directory. It
will be run in the container:
```
#!/bin/bash
pg_dump -c -U superset superset > /superset_backup/$(date +%Y%m%dT%H%M%SUTC
-u)-backup.sql
```
Back on the host, I created another bash script to call this backup script
via docker exec:
```
#!/usr/bin/bash
/usr/bin/docker exec superset_db /superset_backup/scripts/backup.sh
pbzip2 /home/superset/superset_backup/*-backup.sql
```
I set a cronjob to run this regularly. To restore, start with a clean Docker
install, then load into the database. The -c in the pg_dump will cause existing
objects to be dropped, so shouldn't be a problem.
The other thing I do is a daily backup of the superset volumes, after shutting
down superset. It creates a few minutes of downtime, which is acceptable on
this project. To restore those, I shut down docker and replace the superset_db
volume from the backup. This seems to work fine and is clean, just be mindful
of permissions.
Whatever your approach, test test test!
GitHub link:
https://github.com/apache/superset/discussions/17790#discussioncomment-15154279
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]