{"id":15019657,"url":"https://github.com/savitar-hub/postgres-backup","last_synced_at":"2026-01-18T18:01:57.722Z","repository":{"id":65458060,"uuid":"592492832","full_name":"Savitar-Hub/postgres-backup","owner":"Savitar-Hub","description":"Automatise creation of Postgres backups on multiple bucket cloud providers and regions","archived":false,"fork":false,"pushed_at":"2023-01-26T20:52:24.000Z","size":83,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-12T04:35:43.125Z","etag":null,"topics":["backup","google-cloud","postgres","postgresql","postgresql-database"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Savitar-Hub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-23T21:02:36.000Z","updated_at":"2024-01-17T09:50:22.000Z","dependencies_parsed_at":"2023-02-14T23:46:04.827Z","dependency_job_id":null,"html_url":"https://github.com/Savitar-Hub/postgres-backup","commit_stats":null,"previous_names":["nil-andreu/postgres-backup"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savitar-Hub%2Fpostgres-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savitar-Hub%2Fpostgres-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savitar-Hub%2Fpostgres-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Savitar-Hub%2Fpostgres-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Savitar-Hub","download_url":"https://codeload.github.com/Savitar-Hub/postgres-backup/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247135147,"owners_count":20889421,"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":["backup","google-cloud","postgres","postgresql","postgresql-database"],"created_at":"2024-09-24T19:53:51.215Z","updated_at":"2026-01-18T18:01:57.717Z","avatar_url":"https://github.com/Savitar-Hub.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Backup Postgres Database\n\n\n[![Downloads](https://static.pepy.tech/personalized-badge/postgres-backup?period=month\u0026units=none\u0026left_color=grey\u0026right_color=blue\u0026left_text=Downloads)](https://pepy.tech/project/postgres-backup) ![Version](https://img.shields.io/badge/version-0.3.3-blue) ![Python-Version](https://img.shields.io/badge/python-3.9-blue) ![issues](https://img.shields.io/github/issues/Nil-Andreu/postgres-backup) ![PyPI - Status](https://img.shields.io/pypi/status/postgres-backup) ![License](https://img.shields.io/github/license/Nil-Andreu/postgres-backup)\n\n\n## Basic Usage\n\nThis simple Python package allows you to create easily the database backup of Postgres databases.\nYou can upload them to cloud storage buckets by creating a cron job.\n\n```python\n    from postgres_backup import Backup\n\n    # Instantiate the backup object with Postgres database_uri\n    backup = Backup()\n\n    # Create the file for backup\n    backup.create()\n```\n\nYou should have as environment variable `DATABASE_URL`, which is the URI of the Postgres database.\nThis URI has the following structure: `db:engine:[//[user[:password]@][host][:port]/][dbname]`.\n\nCan also specify a list of the tables for which you want to create the backup:\n```python\n    backup.create(table_names=['table1', 'table2', ...])\n```\n\n## Why?\n\nThis package has proved experience of working well for databases of small-mid size.\n\nDoing this, you make sure you can store your database backups without relying in only one cloud provider or region.\n\n## Bucket Storage\n\nHave provided the ability to store those backups in cloud buckets.\n\n### Google Cloud Storage\n\nFor using this functionality, you need to install the dependencies needed of the package:\n\n```bash\n    pip3 install \"postgres-backup[gcs]\"\n```\nThis basically will install also the `google` package.\n\nAnd then after we have the backup created, we would keep following with:\n```python\n    # Upload it to google cloud storage\n    backup.upload(\n        provider=CloudProviders.gcs.value,\n    )\n```\n\nWhere the `google_cloud_certification` is a dictionary, with the key-values of the client api keys:\n```python\n    google_cloud_credentials = {\n      \"type\": \"service_account\",\n      \"project_id\": \"xxx-saas\",\n      \"private_key_id\": \"xxxxxxxx\",\n      \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nxxxxxxxxxx\\n-----END PRIVATE KEY-----\\n\",\n      \"client_email\": \"xxx@xxx-saas.iam.gserviceaccount.com\",\n      \"client_id\": \"xxx\",\n      \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n      \"token_uri\": \"https://oauth2.googleapis.com/token\",\n      \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n      \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/xxx%xxx-saas.iam.gserviceaccount.com\"\n    }\n```\n\nRecommended to provide each key as an environmental variable:\n- GOOGLE_CLOUD_TYPE -\u003e type\n- GOOGLE_CLOUD_PROJECT_ID -\u003e project_id\n- GOOGLE_CLOUD_PRIVATE_KEY_ID -\u003e private_key_id\n- GOOGLE_CLOUD_PRIVATE_KEY -\u003e private_key\n- GOOGLE_CLOUD_CLIENT_EMAIL -\u003e client_email\n- GOOGLE_CLOUD_CLIENT_ID -\u003e client_id\n- GOOGLE_CLOUD_AUTH_URI -\u003e auth_uri\n- GOOGLE_CLOUD_TOKEN_URI -\u003e token_uri\n- GOOGLE_CLOUD_AUTH_PROVIDER_X509_CERT_URL -\u003e auth_provider_x509_cert_url\n- GOOGLE_CLOUD_CLIENT_X509_CERT_URL -\u003e client_x509_cert_url\n\nMoreover `PROJECT_NAME` and `BUCKET_NAME` of the google bucket, and finally `DATABASE_URL` of Postgres database.\n\n\nIn the case that we do not have a bucket already created for storing the backups, we could add additional parameters to create it:\n```python\n    from postgres_backup.schemas import CloudStorageType, CloudProviders\n\n    backup.upload(\n        provider=CloudProviders.gcs.value,\n        bucket_name=bucket_name,\n        create_bucket=True,\n        storage_class=CloudStorageType.NEARLINE.value\n    )\n```\n\n\n### Amazon Web Services\n\nFor uploading into AWS after having created the backup, you need first to install the optional dependencies:\n\n```bash\n    pip3 install \"postgres-backup[aws]\"\n```\n\nAfter that, you can use the method of `upload` of the Backup as:\n\n```python\n    # Upload it to aws storage\n    backup.upload(\n        provider=CloudProviders.aws.value,\n    )\n```\n\nIt requires you to have as environmental variables `AWS_SERVER_PUBLIC_KEY`, `AWS_SERVER_PRIVATE_KEY` and `REGION_NAME`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavitar-hub%2Fpostgres-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsavitar-hub%2Fpostgres-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavitar-hub%2Fpostgres-backup/lists"}