Skip to main content

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

Metadata

Release files for django-simple-backups 1.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-backups 1.9.2
File Size Uploaded
django-simple-backups-1.9.2.tar.gz 5.0 kB Details

Release files / django-simple-backups-1.9.2.tar.gz

Download URL django-simple-backups-1.9.2.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
acb513f55f286213085f10ab076387b2301eac7cd20fba8156c8951c67057b8d
BLAKE2b-256 checksum
How to use checksums
17e750678858b427bef1efc77fe1dc75315fdea7299a4d8494c5cbafb64ee0d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release history Release notifications | RSS feed

This release

1.9.2 This release

1 release file

1.9.1

1 release file

1.9

1 release file

1.8

1 release file

1.7

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

1 release file

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page