Sets up PostgreSQL with automated, encrypted backups to remote storage using Rclone and Age.
- PostgreSQL Database (with pg_vector extension)
- Automated daily backups (configurable)
- Client-side encryption via Age
- Uploads via Rclone to configured remote storage
- Only uploads if data has changed
- Retains backups for a configurable number of days
- DB can be connected from host or another container
- Optional: Telegram notifications when backups fail
- Create .env file: Modify
env_sample
in the project root and save it as.env
. - Start PostgreSQL: Run
sudo docker compose up --build -d
to start PostgreSQL and automated backups. - (Optional) Test Backup: Run
sudo docker compose logs backup -f
to check the backup process.
- Connect using a client (e.g.,
psql
) tolocalhost:5432
(or the mapped port specified indocker-compose.yml
). - Use the
POSTGRES_USER
andPOSTGRES_PASSWORD
from your.env
file.
psql -h localhost -p 5432 -U your_db_user -d your_initial_db
Adminer is a lightweight database management tool. You can run it as a separate Docker container.
Open Adminer: Navigate to http://localhost:8080
in your web browser.
If you have another application running in a Docker container and want it to connect to this PostgreSQL database, ensure both containers are on the same Docker network.
# --- Example: Another application container's docker-compose.yaml ---
services:
my_app:
image: your_app_image
restart: always
environment:
DATABASE_URL: "postgresql://pg_user:pg_password@postgres:5432/app_database"
networks:
- shared_net
networks:
shared_net:
external: true
name: postgres_network # use the same network as the PostgreSQL container
- Download the
.sql.gz.age
backup file from your Rclone remote. - Decrypt:
age -d -i /path/to/private.key backup.sql.gz.age > backup.sql.gz
- Unzip:
gunzip backup.sql.gz
- Restore:
psql -h localhost -U your_db_user -d your_target_db < backup.sql