Backups

Whenever I can, I default to a postgres container. It makes it easier to manage all the backups and configurations for databases across all services in my stack.

To dump the contents of a postgres container, I use the following command:

docker exec postgres pg_dump -U username -F t database | gzip > container-$(date +%Y-%m-%d).tar.gz3

This writes a compressed dump file of the database contents. I have not tested how to reconfigure the database after the backup, I will write this out when I figure it out.

Making a Table

To configure a new postgres instance with table, use the following commands:

docker exec -it postgres psql -U postgres
 
CREATE USER username WITH PASSWORD password;
CREATE DATABASE name 
WITH OWNER = username
	TEMPLATE template0;