{"id":18358575,"url":"https://github.com/mintel/k8s-gcloud-sql-export","last_synced_at":"2026-04-29T07:35:19.363Z","repository":{"id":92837111,"uuid":"247073426","full_name":"mintel/k8s-gcloud-sql-export","owner":"mintel","description":"Helper to run Google CloudSQL exports into a GCS bucket.","archived":false,"fork":false,"pushed_at":"2020-09-21T16:50:18.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-01T03:48:10.444Z","etag":null,"topics":["backup","gcloud","kubernetes","sql"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mintel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2020-03-13T13:07:17.000Z","updated_at":"2023-05-03T07:18:31.000Z","dependencies_parsed_at":"2023-03-06T13:15:33.044Z","dependency_job_id":null,"html_url":"https://github.com/mintel/k8s-gcloud-sql-export","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mintel/k8s-gcloud-sql-export","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintel%2Fk8s-gcloud-sql-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintel%2Fk8s-gcloud-sql-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintel%2Fk8s-gcloud-sql-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintel%2Fk8s-gcloud-sql-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mintel","download_url":"https://codeload.github.com/mintel/k8s-gcloud-sql-export/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mintel%2Fk8s-gcloud-sql-export/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32416146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["backup","gcloud","kubernetes","sql"],"created_at":"2024-11-05T22:18:34.514Z","updated_at":"2026-04-29T07:35:19.338Z","avatar_url":"https://github.com/mintel.png","language":"Shell","readme":"# k8s-gcloud-sql-export\n\nAn image for exporting mysql databases using `gcloud sql export`, and pushing them to a Google bucket.\n\n## Prerequisites\n\n### Google Resources\n\n- A Google bucket into which dumps will be copied.\n- A service-account to peform the backup \n    - Requires `roles/cloudsql.viewer`\n* Permissions to enable the DB instance to write (and read) to/from the bucket\n    - Requires\n        - `roles/storage.legacyBucketWriter`\n        - `roles/storage.legacyBucketReader`\n        - `roles/storage.objectViewer`\n\n### Environment Variables\n\n| Variable Name                  | Description                                                          | Default | Required |\n|--------------------------------|----------------------------------------------------------------------|---------|----------|\n| TRACE                          | Enable script tracing                                                | \"\"      | no       |\n| GCLOUD_VERBOSITY               | Verbosity option passed through to `gcloud`                          | debug   | no       |\n| GCLOUD_WAIT_TIMEOUT            | Timeout (s) passed through to `gcloud sql operations wait`           | 600     | no       |\n| GOOGLE_APPLICATION_CREDENTIALS | The Google Applicaiton Credentials                                   | \"\"      | no       |\n| GOOGLE_PROJECT_ID              | The Google Project ID                                                | \"\"      | yes      |\n| GOOGLE_SQL_INSTANCE_NAME       | Name of SQL instance                                                 | N/A     | yes      |\n| GOOGLE_SQL_BACKUP_BUCKET_PATH  | Name of GCS bucket sub-path to export file into                      | N/A     | yes      |\n| GOOGLE_SQL_BACKUP_BUCKET       | Name of GCS bucket to export to                                      | N/A     | yes      |\n| DATABASE                       | Name of SQL database to export                                       | N/A     | yes      |\n| BACKUP_FILENAME                | Backup filename to use, otherwise determined by timestamp            | \"\"      | no       |\n| BACKUP_SCHEDULE                | Create `hourly` or `nightly` backups (forces the creation timestamp) | none    | no       |\n\n## Usage\n\n### Kubernetes\n\nSee [cronjob-example.yaml](./hack/cronjob-example.yaml) in the `hack` directory.\n\n### Docker\n\nCreate a `.env` file similar to:\n\n```\nGOOGLE_SQL_BACKUP_BUCKET=my-bucket-name\nGOOGLE_SQL_BACKUP_BUCKET_PATH=some-folder/some-sub-folder\nGOOGLE_SQL_INSTANCE_NAME=my-database-instance-name\nGOOGLE_APPLICATION_CREDENTIALS=/tmp/sa/creds.json\nDATABASE=my-database-name\n```\n\nCreate a service-account for the database instance with the role `roles/cloudsql-viewer` and place\ninto `/tmp/sa/creds.json`\n\n```sh\ndocker build -t k8s-gcloud-export .\ndocker run -it --env-file .env -v /tmp/sa:/tmp/sa k8s-gcloud-export \n```\n\n## `BACKUP_SCHEDULE`\n\nIn the default case (`none`), backup files are generated with a timestamp of `now`.\n\nA filename in GCS will look something like:\n\n```\ngs://bucket/bucket-path/2020-03-13T12:36:14+0000_instance-name_db-name.gz\n```\n\nSetting `BACKUP_SCHEDULE` to `hourly` would generate:\n\n```\ngs://bucket/bucket-path/2020-03-13T12:00:00_instance-name_db-name.gz\n```\n\nSetting `BACKUP_SCHEDULE` to `nighly` would generate:\n\n\n```\ngs://bucket/bucket-path/2020-03-13T00:00:00_instance-name_db-name.gz\n```\n\nIn addition to forcing a timestamp, enabling this feature also checks for the existence of the file in the bucket. \n\nIf the file exists, the script exits (0) without performing the backup.\n\nThe use-case for this is to catch issues where multiple runs of the script can queue up (common in k8s if you shutdown\ninstances).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintel%2Fk8s-gcloud-sql-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmintel%2Fk8s-gcloud-sql-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmintel%2Fk8s-gcloud-sql-export/lists"}