4 database - sinus-x/rubbergoddess GitHub Wiki
Database
The Docker containers are Alpine linux boxes, which means that you can open shell inside of them:
docker exec -it rubbergoddess_db_1 sh
To connect to the database, run
# docker (shell is already opened)
psql -U postgres -p 5432
# docker
docker exec -it rubbergoddes_db_1 psql -U postgres -p 5432
# standalone
psql
Once the psql shell is ready, you can display all databases with \l
, all tables with \dt
and use standard SQL queries like SELECT * FROM users
.
Backups
Please note that migration between docker and standalone installation is possible, but requires some manual editing of the dump file:
- Cut down database operations
- Rename database (
postgres
torubbergoddess
) DROP
all existing tables
You should have at least basic knowledge of SQL before you do this.
Docker
# backup
docker exec -it rubbergoddess_db_1 pg_dumpall -c -U postgres > "~/backups/dump_`date +%Y-%m-%d"_"%H-%M-%S`.sql"
# restore
cat dump.sql | docker exec -it rubbergoddess_db_1 psql -U postgres
Standalone
# backup
pg_dump rubbergoddess > "~/backups/dump_`date +%Y-%m-%d"_"%H:%M:%S`.sql"
# restore
cat dump.sql | psql
Automatic backups
Rubbergoddess provides a helper script for both hosting options. You can set up a cron job to do the backup (every day at 5AM in this example) with crontab -e
:
# docker
0 5 * * * bash ~/rubbergoddess/resources/backup.docker.sh >> ~/backup.log 2>&1
# standalone
0 5 * * * bash ~/rubbergoddess/resources/backup.standalone.sh >> ~/backup.log 2>&1
Make sure that the script has executable bit setup. (chmod +x resources/backup._.sh
)
Note: The database contains sensitive information (e-mails) and IS NOT encrypted. It is up to you to comply with the GDPR rules: limiting access to the server and/or encrypting.