https://github.com/arthurdw/cloud-sdk-pg
Utility container for postgres backups to google cloud storage (container with the google cloud sdk installed and postgres client)
https://github.com/arthurdw/cloud-sdk-pg
backup cloud docker google kubernetes oci postgres
Last synced: about 1 year ago
JSON representation
Utility container for postgres backups to google cloud storage (container with the google cloud sdk installed and postgres client)
- Host: GitHub
- URL: https://github.com/arthurdw/cloud-sdk-pg
- Owner: Arthurdw
- License: mit
- Created: 2024-08-28T11:41:59.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-24T01:37:51.000Z (over 1 year ago)
- Last Synced: 2024-10-24T13:13:43.726Z (over 1 year ago)
- Topics: backup, cloud, docker, google, kubernetes, oci, postgres
- Language: Dockerfile
- Homepage: https://hub.docker.com/r/arthurdw/cloud-sdk-pg
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Cloud Postgres Image

This Docker image is designed for use of the Google Cloud SDK and Postgres client. This can be used for example to perform backups of a Postgres instance to Google Cloud Storage.
## Features
- **Base Image**: Built on the latest image of the google cloud SDK
- **Postgres Client**: The Postgres client is installed in the image
## Installation
You can pull this image from Docker Hub by running:
```bash
docker pull arthurdw/cloud-sdk-pg:latest
```
## Usage
This image is intended for use in pods or cron jobs that need to interact with Google Cloud and Postgres. You can run the image interactively to use the Google Cloud SDK and Postgres client:
```bash
docker run -it --rm arthurdw/cloud-sdk-pg
```
Once inside the container, you can use `kubectl` to manage your Kubernetes resources. For example:
```bash
kubectl get pods
```
## Example Deployment
You can use it in a Kubernetes cron job:
```yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: postgres-backup
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
serviceAccountName: impersonator-sa
containers:
- name: backup
image: arthurdw/cloud-sdk-pg:latest
command: ["/bin/sh", "-c"]
args:
- |
gcloud config set auth/impersonate_service_account impersonated-sa@.iam.gserviceaccount.com &&
TIMESTAMP=$(date +%Y%m%d%H%M%S) &&
BACKUP_FILE="/tmp/backup_$TIMESTAMP.sql" &&
pg_dump -h postgres -U postgres -F c -b -v -f $BACKUP_FILE postgres &&
gsutil cp $BACKUP_FILE gs:///backups/
restartPolicy: OnFailure
```
## Contributing
If you have suggestions for improvements or new features, feel free to submit a pull request or open an issue in this repository.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.