A Django app to add simple database and media backups.
Project description
django-simple-backups
Introduction
This django app gives you a simple management command to backup your sqlite or mysql database and media files to dropbox. This was created because had countless errors for me and it was easier to just create a new package. All contributions are welcome. Please just submit a pull request with a short description of the fix or new feature added. Please note currently this app will not delete old backups. if you want to delete backups then you have to go to dropbox and do it yourself.
Installation
pip install django-simple-backups
Add backups
to your Django settings INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"backups",
]
Settings
# other required settings
# must use default database and must use 'ENGINE': 'django.db.backends.sqlite3' or 'ENGINE': 'django.db.backends.mysql',
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
...
}
}
# must have MEDIA_ROOT
# must be to absolute path
MEDIA_ROOT = BASE_DIR / 'somepath'
# simple backups settings
# must have refresh token, app_key, app_secret
# how to get refresh token stackoverflow.com/a/71794390/14665310]
SIMPLE_BACKUPS_DROPBOX_REFRESH_TOKEN = "<refresh_token>"
# get app key from dropbox.com/developers => choose your app => find app key
SIMPLE_BACKUPS_DROPBOX_APP_KEY = '<app_key>'
# get app key from dropbox.com/developers => choose your app => find app key
SIMPLE_BACKUPS_APP_SECRET = "<app_secret>"
# folder in drop box to save all database files to default is "/database/"
SIMPLE_BACKUPS_DROPBOX_DATABASE_PATH = "/database/"
# folder in drop box to save all media folders to. | for each backup a folder with todays date will be added your website media files will get added to that folder
# default is "/media/"
SIMPLE_BACKUPS_DROPBOX_MEDIA_PATH = "/media/"
# format of the date that the backups will use to rename
# see for date codes https://www.w3schools.com/python/gloss_python_date_format_codes.asp
# default is "%c" - Mon Dec 31 17:41:00 2018
SIMPLE_BACKUPS_DROPBOX_RENAME_DATE_FORMAT = "%c"
# set this to true (default false) if you want the mysql files to be gzipped before being uploaded to dropbox.
SIMPLE_BACKUPS_USE_GZIP = True
Management commands
manage.py backupmedia
creates a new folder in dropbox with the current date as the name of the folder. For example if your media folder structure looks like:
media
| file one
| file two
| documents
| | document one
then your uploaded dropbox folder will look like
SIMPLE_BACKUPS_DROPBOX_MEDIA_PATH/current_date media backup
| file one
| file two
| documents
| | document one
manage.py backupdatabase
- copies your database
- uploads to dropbox at
SIMPLE_BACKUPS_DROPBOX_DATABASE_PATH/current_date | db.sqlite3
changelog
1.9 added gzipping sql file backups only used for django.db.backends.mysql
1.8 fixed problem with mysql database not authenticating with password with special characters.
1.7 added mysql backup support
1.6 uses refresh token instead of authentication token must add these settings
SIMPLE_BACKUPS_DROPBOX_REFRESH_TOKEN = "<refresh_token>"
SIMPLE_BACKUPS_DROPBOX_APP_KEY = '<app_key>'
SIMPLE_BACKUPS_APP_SECRET = "<app_secret>"
see how to get refresh token | removed SIMPLE_BACKUPS_DROPBOX_ACCESS_TOKEN setting
1.5 added dependencies to the installation
1.1 fixed issue installing library in django
1.0 first release
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-simple-backups-1.9.2.tar.gz
.
File metadata
- Download URL: django-simple-backups-1.9.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | acb513f55f286213085f10ab076387b2301eac7cd20fba8156c8951c67057b8d |
|
MD5 | 7b606cbc0e80978b039d6373a7fea12b |
|
BLAKE2b-256 | 17e750678858b427bef1efc77fe1dc75315fdea7299a4d8494c5cbafb64ee0d0 |