This repository provides a set of scripts for automating PostgreSQL database backups in a development environment, particularly tailored for use with Gitpod. It allows for easy database initialization, periodic backups, and manual backups, all integrated with Git for version control.
- Automatic initialization of PostgreSQL database from the latest backup
- Perform manual backups
- Schedule periodic backups
- Automatically commit and push backups to the Git repository
The easiest way to get started is to open this project in Gitpod:
- Click the "Open in Gitpod" button above.
- Wait for the Gitpod workspace to start and initialize.
That's it! The database will be automatically set up and periodic backups will start running.
init-postgres.sh
: Initializes the PostgreSQL database from the latest backup.backup-postgres.sh
: Performs a manual backup of the database.periodic-backup-postgres.sh
: Sets up periodic backups of the database.
The .gitpod.yml
file in this repository takes care of the initialization process. It:
- Uses a custom Dockerfile for the workspace environment.
- Automatically runs the initialization script.
- Starts the periodic backup process.
- Sets up the necessary ports for PostgreSQL.
While the Gitpod configuration automates most processes, you can still manually interact with the scripts if needed:
To perform a manual backup:
bash .gitpod/backup-postgres.sh
This will create a backup of your database, commit it to Git, and push it to the remote repository.
You can customize the backup frequency, database name, and other parameters by modifying the .env
file in the .gitpod
directory.