{"id":21174613,"url":"https://github.com/leen15/backup-databases-to-s3","last_synced_at":"2025-07-09T21:30:57.131Z","repository":{"id":84736805,"uuid":"355269573","full_name":"Leen15/backup-databases-to-s3","owner":"Leen15","description":"Backup multiple types of database to Amazon S3 with cronjob with a simple docker image.","archived":false,"fork":false,"pushed_at":"2025-07-08T06:51:33.000Z","size":36,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-08T07:33:35.171Z","etag":null,"topics":["aws","docker","kubernetes","s3"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Leen15.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-06T17:09:06.000Z","updated_at":"2025-07-08T06:51:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e84f4f3-993a-4afc-8ed5-3b538249c142","html_url":"https://github.com/Leen15/backup-databases-to-s3","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Leen15/backup-databases-to-s3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leen15%2Fbackup-databases-to-s3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leen15%2Fbackup-databases-to-s3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leen15%2Fbackup-databases-to-s3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leen15%2Fbackup-databases-to-s3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Leen15","download_url":"https://codeload.github.com/Leen15/backup-databases-to-s3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Leen15%2Fbackup-databases-to-s3/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264503949,"owners_count":23618762,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","docker","kubernetes","s3"],"created_at":"2024-11-20T16:55:25.510Z","updated_at":"2025-07-09T21:30:57.125Z","avatar_url":"https://github.com/Leen15.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backup databases to Amazon S3 via cron\n\nThis image dumps your databases every hour (OR custom cron defined in `BACKUP_CRON_SCHEDULE`),\ncompresses the dump using bz2 and uploads it to an amazon S3 bucket.\nWith a valid `AWS_KEEP_FOR_DAYS` backups older than that days are deleted automatically (on the same path).\nIt also have a `BACKUP_PRIORITY` params for set the backup priority with ionice and nice values.\n\nAt the moment, it supports:\n- PostgreSQL (pg_dump, versions \u003c= 17)\n- MySQL (mysqldump, versions 5.7+ )\n- ClickHouse (versions 25+)\n\nConfigure the backup source and s3 target with these environment\nvariables:\n\n- `AWS_REGION` (for example `eu-central-1`)\n- `AWS_ACCESS_KEY_ID`\n- `AWS_SECRET_ACCESS_KEY`\n- `AWS_BUCKET_NAME`\n- `AWS_BUCKET_PATH`\n- `AWS_KEEP_FOR_DAYS`\n- `AWS_SHOW_UPLOAD_PROGRESS` (ex. `true`)\n- `BACKUP_CRON_SCHEDULE`\n- `BACKUP_PRIORITY` (default `ionice -c 3 nice -n 10`)\n- `COMPRESSION_PRIORITY` (ex. `ionice -c 3 nice -n 10`, null as default)\n- `DB_TYPE` (allowed types: `postgres` | `mysql` | `clickhouse`)\n- `DB_HOST`\n- `DB_NAME`\n- `DB_TABLE` (used and mandatory only with ClickHouse )\n- `DB_PORT`\n- `DB_USER`\n- `DB_PASSWORD`\n- `DB_OPT_PARAMS` (for example with mysql `--lock-tables=false --single-transaction --quick` )\n\n\n## Usage\n\nYou can you this image in two different ways:\n- Using the internal cronjob\n- Using oneshot\n- Using with a k8s cronjob\n\n### Internal CronJob Example:\n`docker run -it --env-file .env leen15/db-backup-to-s3`\nBy default it will run every hour.\n\n### Oneshot Example:\n`docker run -it --env-file .env --entrypoint '/backup/backup.sh' leen15/db-backup-to-s3`\n\n### K8s cronjob Example:\n```yaml\napiVersion: batch/v1beta1\nkind: CronJob\nmetadata:\n  name: Database Backup\nspec:\n  schedule: \"0 * * * *\"\n  jobTemplate:\n    spec:\n      template:\n        spec:\n          containers:\n          - name: db-backup\n            image: leen15/db-backup-to-s3\n            imagePullPolicy: IfNotPresent\n            command:\n            - /backup/backup.sh\n            env:\n            - name: AWS_ACCESS_KEY_ID\n              value: keyID\n            - name: AWS_SECRET_ACCESS_KEY\n              value: secretKey\n            - name: AWS_DEFAULT_REGION\n              value: eu-west-1\n            - name: AWS_BUCKET_NAME\n              value: backups\n            - name: AWS_BUCKET_PATH\n              value: db-dumps/my-database\n            - name: DB_TYPE\n              value: mysql\n            - name: DB_HOST\n              value: db\n            - name: DB_NAME\n              value: my-database\n            - name: DB_PORT\n              value: 3306\n            - name: DB_USER\n              value: user\n            - name: DB_PASSWORD\n              value: password\n            - name: DB_OPT_PARAMS\n              value: --lock-tables=false --single-transaction --quick\n          restartPolicy: OnFailure\n```\n\n## Thanks\n\nAdapted from [here](https://blog.danivovich.com/2015/07/23/postgres-backups-to-s3-with-docker-and-systemd/), [here](http://blog.oestrich.org/2015/01/pg-to-s3-backup-script/) and [here](https://www.ekito.fr/people/run-a-cron-job-with-docker/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleen15%2Fbackup-databases-to-s3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleen15%2Fbackup-databases-to-s3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleen15%2Fbackup-databases-to-s3/lists"}