django-sync-env


Namedjango-sync-env JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryBackup, Sync and Restore Databases and Media
upload_time2025-10-09 02:49:31
maintainerNone
docs_urlNone
authorDan Brosnan
requires_python<4.0,>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django sync env

django-sync-env is a Django app to manage backing up and restoring django databases and media assets easily.

Detailed documentation is in the "docs" directory (it's a work in progress).


## Requirements:
- configurable backups and restore which can be run on demand, celery cron or in dev.
- support s3 bucket and file storage options first, add azure blob storage later
- interactive prompts for local dev
- command line options with --no-input for CICD and automations
- restore latest option for media and backups for X env
- backup before restore option


## Setup

1. Add "django_sync_env" to your INSTALLED_APPS setting like this:

```
   INSTALLED_APPS = [
   ...,
   "django_sync_env",
   ]
```

2. Configure the app via a settings file .typically `./settings/partial/sync_env.py` for base configuration,
   don't forget to import this file via your base.py settings file
   And override any required settings per environment via `./settings/partials/[env].py`
   see [example_partials](docs/example_partials.md)

There is a [s3 terraform example](docs/example_terraform_aws_s3_bucket.md) for provisioning
an aws s3 bucket, iam user, roles and policy to allow for remote backup/restore to/from a secure s3 bucket.

See [management commands](docs/management_commands.md) for more details for each of the commands available.

- `./manage.py sync_env_backup_db` [usage](docs/management_commands.md#managepy-syncenvbackupdb)
- `./manage.py sync_env_backup_media`
- `./manage.py sync_env_restore_db`
- `./manage.py sync_env_restore_media`
- `./manage.py sync_env_list_backups`

See [Tasks](docs/tasks.md) for more details for each of the tasks available.

## Development and Publishing
See [documentation](docs/development_and_release_notes.md). 

## Existing project migration

* To run db backup manually without storing anything on the local server you can run following command
```shell
export AWS_ACCESS_KEY_ID="<backup-user-key>"
export AWS_SECRET_ACCESS_KEY="<backup-user-secret>"

pg_dump --dbname="postgresql://<db-user>:<db-password>@<db-host>:5432/<db-name>" --format=custom | gzip --stdout | aws s3 cp - "s3://<project-name>-<env>-backups/<sensible-name-here>-<db-name>-$(date +'%d-%m-%Y-%H%M%S').psql.bin.gz"
```
* After that you can restore this database backup using `./manage.py sync_env_restore_db`

## TODO:
- remove command options which we wont use
- make sure all management commands work with good error logging and handling
- Update the sync-env-backup command to enable the option to specify particular databases
- Update the sync-env-backup command to exclude particular tables in particular databases



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-sync-env",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Dan Brosnan",
    "author_email": "dan.brosnan@octave.nz",
    "download_url": "https://files.pythonhosted.org/packages/d0/20/321b9ac2c84ba15f464445908b3b26b748c8a7c58f7ecb1ec6e3f5cb7790/django_sync_env-1.0.1.tar.gz",
    "platform": null,
    "description": "# Django sync env\n\ndjango-sync-env is a Django app to manage backing up and restoring django databases and media assets easily.\n\nDetailed documentation is in the \"docs\" directory (it's a work in progress).\n\n\n## Requirements:\n- configurable backups and restore which can be run on demand, celery cron or in dev.\n- support s3 bucket and file storage options first, add azure blob storage later\n- interactive prompts for local dev\n- command line options with --no-input for CICD and automations\n- restore latest option for media and backups for X env\n- backup before restore option\n\n\n## Setup\n\n1. Add \"django_sync_env\" to your INSTALLED_APPS setting like this:\n\n```\n   INSTALLED_APPS = [\n   ...,\n   \"django_sync_env\",\n   ]\n```\n\n2. Configure the app via a settings file .typically `./settings/partial/sync_env.py` for base configuration,\n   don't forget to import this file via your base.py settings file\n   And override any required settings per environment via `./settings/partials/[env].py`\n   see [example_partials](docs/example_partials.md)\n\nThere is a [s3 terraform example](docs/example_terraform_aws_s3_bucket.md) for provisioning\nan aws s3 bucket, iam user, roles and policy to allow for remote backup/restore to/from a secure s3 bucket.\n\nSee [management commands](docs/management_commands.md) for more details for each of the commands available.\n\n- `./manage.py sync_env_backup_db` [usage](docs/management_commands.md#managepy-syncenvbackupdb)\n- `./manage.py sync_env_backup_media`\n- `./manage.py sync_env_restore_db`\n- `./manage.py sync_env_restore_media`\n- `./manage.py sync_env_list_backups`\n\nSee [Tasks](docs/tasks.md) for more details for each of the tasks available.\n\n## Development and Publishing\nSee [documentation](docs/development_and_release_notes.md). \n\n## Existing project migration\n\n* To run db backup manually without storing anything on the local server you can run following command\n```shell\nexport AWS_ACCESS_KEY_ID=\"<backup-user-key>\"\nexport AWS_SECRET_ACCESS_KEY=\"<backup-user-secret>\"\n\npg_dump --dbname=\"postgresql://<db-user>:<db-password>@<db-host>:5432/<db-name>\" --format=custom | gzip --stdout | aws s3 cp - \"s3://<project-name>-<env>-backups/<sensible-name-here>-<db-name>-$(date +'%d-%m-%Y-%H%M%S').psql.bin.gz\"\n```\n* After that you can restore this database backup using `./manage.py sync_env_restore_db`\n\n## TODO:\n- remove command options which we wont use\n- make sure all management commands work with good error logging and handling\n- Update the sync-env-backup command to enable the option to specify particular databases\n- Update the sync-env-backup command to exclude particular tables in particular databases\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Backup, Sync and Restore Databases and Media",
    "version": "1.0.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a5bfc6c02e51d0654ca1f416a4c20a69c1f86b61b9bdb355993fde5c2d8897d4",
                "md5": "26c2e8e174e75d9bdc201275b7becb41",
                "sha256": "33c60c5cdc7e5e6df30163764aacd42e1cbb79cad9902d18efccfdce6bf1bb4e"
            },
            "downloads": -1,
            "filename": "django_sync_env-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26c2e8e174e75d9bdc201275b7becb41",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 34214,
            "upload_time": "2025-10-09T02:49:31",
            "upload_time_iso_8601": "2025-10-09T02:49:31.104964Z",
            "url": "https://files.pythonhosted.org/packages/a5/bf/c6c02e51d0654ca1f416a4c20a69c1f86b61b9bdb355993fde5c2d8897d4/django_sync_env-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d020321b9ac2c84ba15f464445908b3b26b748c8a7c58f7ecb1ec6e3f5cb7790",
                "md5": "6503e718605ca2e930e108498d9fdc72",
                "sha256": "5169fb7e3febc46f20fd3f5fe2e42a2626d8099909826741aa010205fefec1d0"
            },
            "downloads": -1,
            "filename": "django_sync_env-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6503e718605ca2e930e108498d9fdc72",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 22316,
            "upload_time": "2025-10-09T02:49:31",
            "upload_time_iso_8601": "2025-10-09T02:49:31.977510Z",
            "url": "https://files.pythonhosted.org/packages/d0/20/321b9ac2c84ba15f464445908b3b26b748c8a7c58f7ecb1ec6e3f5cb7790/django_sync_env-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-09 02:49:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-sync-env"
}
        
Elapsed time: 2.41390s