Skip to main content

dj_backup is an installable module for Django that is used for backup purposes.

Project description

dj_backup

What is this ?

DJ Backup is a Django app that provides the capability to back up your files and databases.

Available at:

supported databases
  • mysql
  • postgres
  • sqlite
supported storages
  • local
  • sftp server
  • ftp server
  • dropbox(beta)
  • telegram bot

How to use ?

1. First you need to install dj_backup

    pip install djbackup

OR

  • for using all features

    pip install djbackup[all]

2. After that, add the dj_backup app to your Django project's installed apps.

    INSTALLED_APPS = [
    ...
    ...
    # apps
    'dj_backup',
]

3. add static files dir path to django

STATICFILES_DIRS = (
    ...
    os.path.join(BASE_DIR, 'dj_backup/static/'),
)

4. add locale file to django(optional)

LOCALE_PATHS = (
    ...
    BASE_DIR/ 'dj_backup/locale',
)

5. add dj_backup urls to project urls

urlpatterns = [
    ...
    path('dj-backup/', include('dj_backup.urls', namespace='dj_backup')),
    ...
]

6. set dj_backup basic config to django settings

DJ_BACKUP_CONFIG = {
    'STORAGES': {
        'LOCAL': {
            'OUT': BASE_DIR / 'backup/result'
        },
    }
}

7. migrate & collect static files

    python manage.py migrate
    python manage.py collectstatic

8. run backup!

  • command is for managing settings and executing backup tasks
    python manage.py run-backup

9. run django

    python manage.py runserver
  • OR use wsgi/asgi handler like: (uwsgi, gunicorn, waitress or etc)

Dashboard

now you can access to dj_backup dashboard

    127.0.0.1:8000/dj-backup/

OR

    xxx.xxx:xxxx/dj-backup/  

Additional Config

DJ_BACKUP_CONFIG = {
    # 'MAX_WORKERS': 5, #(optional)
    # 'NOTIFICATION_OBJECT_LOG_LEVEL': 'WARNING', #(optional)  # options => ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
    # 'POSTGRESQL_DUMP_PATH': None,  # optional(If the postgresql dump file is not found, you can set it)
    # 'MYSQL_DUMP_PATH': None,  # optional(If the mysql dump file is not found, you can set it)
    # 'EXTERNAL_DATABASES': {
    # 'default2': {
    #     'ENGINE': 'postgresql',
    #     'NAME': 'test',
    #     'USER': 'postgres',
    #     'PASSWORD': 'xxx',
    #     'HOST': '127.0.0.1',  # Or an IP Address that your DB is hosted on
    # },
    # 'default3': {
    #     'ENGINE': 'mysql',
    #     'NAME': 'test',
    #     'USER': 'root',
    #     'PASSWORD': 'xxx',
    #     'HOST': '127.0.0.1',  # Or an IP Address that your DB is hosted on
    # },
    # },
    'BASE_ROOT_DIRS': [
        BASE_DIR,
    ],
    # 'BACKUP_TEMP_DIR': BASE_DIR / 'backup/temp', #(optional)
    # 'BACKUP_SYS_DIR': BASE_DIR / 'backup/sys', #(optional)
    'STORAGES': {
        'LOCAL': {
            'OUT': BASE_DIR / 'backup/result'
        },
        # 'TELEGRAM_BOT': {
        #     'BOT_TOKEN': 'xxx-xxx',
        #     'CHAT_ID': 'xxx-xxx'
        # }
        # 'SFTP_SERVER': {
        #     'HOST': 'xxx',
        #     'USERNAME': 'xxx',
        #     'PASSWORD': 'xxx',
        #     'OUT': 'xxx'
        # },
        # 'FTP_SERVER': {
        #     'HOST': "xxx",
        #     'USERNAME': "xxx",
        #     'PASSWORD': "xxx",
        #     'OUT': 'backups'
        # },
        # 'DROPBOX': {
        #     'ACCESS_TOKEN': 'xxx-xxx',
        #     'OUT': '/dj_backup/'
        # }
    }
}
  • To use storage providers or perform database backups, you need to install the appropriate packages according to your needs using the commands below

- storages:

storage install command
TELEGRAM_BOT pip install djbackup[telegram]
SFTP_SERVER pip install djbackup[sftpserver]
FTP_SERVER pip install djbackup[ftpserver]
DROPBOX pip install djbackup[dropbox]

- databases:

database install command
mysql pip install djbackup[mysql]
postgresql pip install djbackup[postgresql]

NOTE:

If you dont need any of the storages, you must remove that configuration
because you get an error if it cant be connected

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djbackup-2.1.0.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

djbackup-2.1.0-py3-none-any.whl (3.7 MB view details)

Uploaded Python 3

File details

Details for the file djbackup-2.1.0.tar.gz.

File metadata

  • Download URL: djbackup-2.1.0.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for djbackup-2.1.0.tar.gz
Algorithm Hash digest
SHA256 781795e04486ba0aeb163a151511c2a4e64565858697aff952ab761ad5f87207
MD5 a9030bb3d420e42604ffd1848d25153d
BLAKE2b-256 64e106c7b6dcd2102325e5ffb18c85aae9a83f96f8d9e07610287648757187f8

See more details on using hashes here.

File details

Details for the file djbackup-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: djbackup-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for djbackup-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b09ac7f1cd9525c4a9b8583f45cb012dbe06fe7793f5c889c302b8106dba177
MD5 d582d64e56ebdf9420fdfa99152aa0dc
BLAKE2b-256 f1b7066f18d7b1f0b53463875a9fecc6c32afb9efdab13f2ddea8fbfc0d73e40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page