This project provides a Dockerized solution to back up a PostgreSQL database and upload the backup file to Google Drive.
- Docker
- Google Cloud Service Account with Google Drive API enabled
-
Pull the Docker image:
docker pull appzic/backup-psql-to-gdrive
-
Set the following environment variables:
DB_NAME: Your PostgreSQL database nameDB_USER: Your PostgreSQL database userDB_PASSWORD: Your PostgreSQL database passwordDB_HOST: Your PostgreSQL database hostDB_PORT: Your PostgreSQL database port (default is 5432)GDRIVE_FOLDER_ID: Your Google Drive folder ID where the backup will be uploadedGDRIVE_AUTH_KEY: Path to your Google Drive service account credentials JSON fileGDRIVE_AUTH_DOMAIN_WIDE_DELEGATION: Your Google Workspace domain (if using domain-wide delegation) (optional)
-
Run the Docker container with the environment variables:
docker run -e DB_NAME=your_db_name \ -e DB_USER=your_db_user \ -e DB_PASSWORD=your_db_password \ -e DB_HOST=your_db_host \ -e DB_PORT=your_db_port \ -e GDRIVE_FOLDER_ID=your_gdrive_folder_id \ -e GDRIVE_AUTH_KEY=/path/to/your/credentials.json \ appzic/backup-psql-to-gdrive -
The backup script will run and upload the PostgreSQL database backup to the specified Google Drive folder.
This project is licensed under the MIT License.