{"id":23497980,"url":"https://github.com/freedomben/db-snapshotter","last_synced_at":"2025-07-22T19:04:01.737Z","repository":{"id":69604946,"uuid":"448165313","full_name":"FreedomBen/db-snapshotter","owner":"FreedomBen","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-15T19:06:34.000Z","size":63,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-22T21:59:03.663Z","etag":null,"topics":[],"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/FreedomBen.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2022-01-15T02:50:27.000Z","updated_at":"2024-11-15T19:06:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"833cd92b-9916-492c-a6eb-1d1808c96a8a","html_url":"https://github.com/FreedomBen/db-snapshotter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FreedomBen/db-snapshotter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fdb-snapshotter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fdb-snapshotter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fdb-snapshotter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fdb-snapshotter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreedomBen","download_url":"https://codeload.github.com/FreedomBen/db-snapshotter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Fdb-snapshotter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266554013,"owners_count":23947252,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-25T05:17:37.645Z","updated_at":"2025-07-22T19:04:01.712Z","avatar_url":"https://github.com/FreedomBen.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# db-snapshotter\n\nSimple script to dump a PostgreSQL or MariaDB database into a .sql.gz file,\nand upload it to object storage (S3 compatible, such as Backblaze).\n\n## Quick Start\n\nYou can find sample Kubernetes manifest in `k8s/examples`.  The configuration\nis passed in to the script via environment variables.  Non sensitive values\nshould be passed through a `ConfigMap`, while sensitive values should use\n`Secret`s.\n\n### 1.  Gather configuration information\n\nYou will need to provide values for the following variables:\n\n- `DB_TYPE:  'postgres'  # || 'mysql'`\n- `AWS_ENDPOINT_URL:   'https://s3.us-west-002.backblazeb2.com'`\n- `TARGET_DATABASE:  'service_name_prod'`\n- `BUCKET_NAME:  'db-backups'`\n- `DB_PORT:  '25060'`\n- `PREFIX:  'daily'`\n- `SERVICE_NAME:  'service_name'`\n- `DB_USERNAME: '\u003credacted\u003e'`\n- `DB_PASSWORD: '\u003credacted\u003e'`\n- `DB_HOSTNAME: '\u003credacted\u003e'`\n- `AWS_ACCESS_KEY_ID: '\u003credacted\u003e'`\n- `AWS_SECRET_ACCESS_KEY: '\u003credacted\u003e'`\n\nOptionally, to enable notifications over Slack, set:\n\n- `SLACK_API_TOKEN:  '\u003ctoken\u003e'`\n- `SLACK_CHANNEL_INFO: '\u003credacted\u003e'`\n- `SLACK_CHANNEL_ERROR: '\u003credacted\u003e'`\n- `SLACK_CHANNEL_SUCCESS: '\u003credacted\u003e'`\n- `SLACK_USERNAME: '\u003credacted\u003e'  # optional customization`\n- `SLACK_ICON_EMOJI: '\u003credacted\u003e'  # optional customization`\n\n\n### 2.  Create Secret\n\nConfigure and create a `Secret` defining the variables.  Here is an example:\n\n```yaml\n---\napiVersion: v1\nkind: Secret\nmetadata:\n  name: db-snapshotter-service-name-secrets\n  namespace: db-snapshotter-prod\n  labels:\n    app: db-snapshotter\ntype: Opaque\nstringData:\n  DB_USERNAME: '\u003credacted\u003e'\n  DB_PASSWORD: '\u003credacted\u003e'\n  DB_HOSTNAME: '\u003credacted\u003e'\n  AWS_ACCESS_KEY_ID: '\u003credacted\u003e'\n  AWS_SECRET_ACCESS_KEY: '\u003credacted\u003e'\n  SLACK_API_TOKEN:  '\u003ctoken\u003e' # optional for slack notifications\n```\n\n### 3.  Update Configuration in `ConfigMap`\n\nYou can use one of the examples in `k8s/examples`\n\n```yaml\n---\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: db-snapshotter-service-name-config\n  namespace: db-snapshotter-prod\n  labels:\n    app: db-snapshotter\ndata:\n  DB_TYPE: 'postgres'  # || 'mysql'\n  AWS_ENDPOINT_URL:  'https://s3.us-west-002.backblazeb2.com'\n  TARGET_DATABASE: 'service_name_prod'\n  BUCKET_NAME: 'db-backups'\n  DB_PORT: '25060'\n  PREFIX: 'daily'\n  SERVICE_NAME: 'service_name'\n  SLACK_CHANNEL_INFO: '#infra-info'                   # channel to send info messages to\n  SLACK_CHANNEL_ERROR: '#infra-error'                 # channel to send error messages to\n  SLACK_CHANNEL_SUCCESS: '#infra-info'                # channel to send success messages to\n  SLACK_USERNAME: 'DB Snapshot for service-name prod' # optional username to post as\n  SLACK_ICON_EMOJI: ':database:'                      # optional emoji to use for avatar\n```\n\n### 4.  Create a `Job` or `CronJob`\n\nIf you only want to run the script once or on demand, create a `Job` object.\nIf you want to run the script periodically, create a `CronJob` object.\n\nHere is an example `CronJob` that will run at 10 PM every day:\n\n```yaml\n---\napiVersion: batch/v1\nkind: CronJob\nmetadata:\n  name: db-snapshotter\n  namespace: db-snapshotter-prod\n  labels:\n    app: db-snapshotter\nspec:\n  schedule: \"0 22 * * *\" # 10 PM every day\n  jobTemplate:\n    metadata:\n      name: db-snapshotter-prod-job\n      namespace: db-snapshotter-prod\n      labels:\n        app: db-snapshotter\n    spec:\n      backoffLimit: 1\n      activeDeadlineSeconds: 1800\n      template:\n        metadata:\n          namespace: db-snapshotter-prod\n          labels:\n            app: db-snapshotter\n        spec:\n          containers:\n          - name: db-snapshotter\n            image: docker.io/freedomben/db-snapshotter:latest\n            imagePullPolicy: Always\n            envFrom:\n              - configMapRef:\n                  name: db-snapshotter-service-name-config\n              - secretRef:\n                  name: db-snapshotter-service-name-secrets\n          restartPolicy: Never\n```\n\n### 5.  Run the Job\n\nIf you created a `Job` it will run immediately.  If you created a `CronJob`\nbut would like to run it immediately for testing purposes (a wise plan), you\ncan create a `Job` from the `CronJob` with:\n\n```bash\nCRONJOB_NAME='db-snapshotter'\nNEW_JOB_NAME=\"db-snapshotter-manual-run-$(date '+%Y-%m-%d-%H-%M-%S')\"\n\nkubectl create job --from=\"cronjob/${CRONJOB_NAME}\" \"${NEW_JOB_NAME}\"\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreedomben%2Fdb-snapshotter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreedomben%2Fdb-snapshotter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreedomben%2Fdb-snapshotter/lists"}