A Django app to create and load backups.
Project description
Django Backup Utils
With django-backup-utils you can:
- create backups with or without compression
- list available backups for your host & project
- restore database
- restore migration files
- restore any directory inside BASE_DIR
Backups are tarfiles that also can be compressed by the programm
A backup always contains
- a full dump of your database as json (using dumpdata)
- all migration .py files that are curently migrated.
- a customizable version stamp (e.g. commit hash)
- identifiers such as hostname, django project name
When restoring a backup
- automatically get the lastest backup for your host + project
- see the backup's version stamp
- see the current version stamp
- see differences between backup und current migrations
- per defalt a blank unittest is run to ensure the fixture can be loaded (before anything is changed)
A log is saved to database for creating/loading backups.
Project-Structure
projectname/
projectname/
__init__.py
settings.py
...
App1 /
migrations /
__init__.py
...
...
Quick start
-
$ pip install django-backup-utils
-
settings.py:
INSTALLED_APPS = [
...
'django_backup_utils.apps.BackupUtilsConfig',
]
BACKUP_ROOT = "/my/path/to/backupdir/"
BACKUP_DIRS = ["media"] # add more if needed
BACKUP_SYSTEM_VERSION = "my_build_id"
BACKUP_ROOT
specifies a directory where your backups will be stored
BACKUP_DIRS
specifies directories that will be included in the backup
BACKUP_SYSTEM_VERSION
identification tag for your backup (e.g. your git commit hash/tag)
$ python3 manage.py migrate
Usage
$ python3 manage.py createbackup
- create a backup that contains all database data, migration files and specified directories
optional arguments:
-h, --help show this help message and exit
--compress compresses backup (.gz)
$ python3 manage.py loadbackup
- load the latest backup
optional arguments:
-h, --help show this help message and exit
--tarpath TARPATH load the specified backup tarfile
--flush flush the database (delete existing data)
--deletedirs delete all directories specified in settings.BACKUP_DIRS (before restoring)
--noinput disable all prompts
--loadmigrations restore all migration files
--skiptest skip the unittest for loading database dump
$ python3 manage.py listbackups
- show backups located at settings.BACKUP_ROOT
optional arguments:
-h, --help show this help message and exit
--hostname HOSTNAME show backups for specified hostname
--projectname PROJECTNAME
show backups for specified django project
--all show all backups
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-backup-utils-0.1.3.tar.gz
.
File metadata
- Download URL: django-backup-utils-0.1.3.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6399eb6d356e7f24244c52e886fb714452b1ab6d037ba22f84d571021670a199 |
|
MD5 | 63a91162cda24d5c63c913d9f5c45781 |
|
BLAKE2b-256 | d1eb42795b267bb361d190009826442653efba25b021ba612de7c32d049cc23b |