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.
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

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

    INSTALLED_APPS = [
    ...
    ...
    # apps
    'dj_backup',
    'django_q'
]
  1. add static files dir path to django
STATICFILES_DIRS = (
    ...
    os.path.join(BASE_DIR, 'dj_backup/static/'),
)
  1. add locale file to django(optional)
LOCALE_PATHS = (
    ...
    BASE_DIR/ 'dj_backup/locale',
)
  1. add dj_backup urls to project urls
urlpatterns = [
    ...
    path('dj-backup/', include('dj_backup.urls', namespace='dj_backup')),
    ...
]

6. set dj_backup config to django settings

    DJ_BACKUP_CONFIG = {
    # optional (if dj_backup cant find `pg_dump` file then you must fill this
    'POSTGRESQL_DUMP_PATH': None,
    # optional (if dj_backup cant find `mysqldump` file then you must fill this
    'MYSQL_DUMP_PATH': None,
    # if you want backup external databases you can set this config
    # By default local databases are accessible and can be backed up
    'EXTERNAL_DATABASES': {
        # 'external_db': {
        #     'ENGINE': 'mysql',
        #     'NAME': 'test',
        #     'USER': 'test',
        #     'PASSWORD': 'test',
        #     'HOST': '127.0.0.1',  # Or an IP Address that your DB is hosted on
        #     'PORT': 3306  # optional
        # },
        ...
        ...
    },
    'BASE_ROOT_DIRS': [
        # the main path for the files that need to be backed up
        BASE_DIR,
        ...
    ],
    'BACKUP_TEMP_DIR': BASE_DIR / 'backup/temp',
    'STORAGES': {
        'LOCAL': {
            'OUT': BASE_DIR / 'backup/result'  # the path local storage
        },
        'SFTP_SERVER': {
            'HOST': 'xxx.xxx.xxx.xxx',
            'USERNAME': 'xxx.xxx.xxx.xxx',
            'PASSWORD': 'xxx.xxx.xxx.xxx',
            'OUT': '/backups'
        },
        'FTP_SERVER': {
            'HOST': "xxx.xxx.xxx.xxx",
            'USERNAME': "xxx.xxx.xxx.xxx",
            'PASSWORD': "xxx.xxx.xxx.xxx",
            'OUT': '/backups'
        },
        'DROPBOX': {
            'ACCESS_TOKEN': 'xxx.xxx.xxx.xxx',
            'OUT': '/backups'
        },
        'TELEGRAM_BOT': {
             'BOT_TOKEN': 'xxx',
             'CHAT_ID': 'xxx'
         }
    }
}

7. migrate & collect static files

    python manage.py migrate
    python manage.py collectstatic

8. run backup!

    python manage.py run-backup

9. Dashboard

now you can access to dj_backup dashboard

    127.0.0.1:8000/dj-backup/

OR

    xxx.xxx:xxxx/dj-backup/  

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.0.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

djbackup-2.0.0-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for djbackup-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b03f24b101d449d14c69a6cf348db5bedeed5b91d353cd8b08f6fa4d62dffb8f
MD5 2ce0247bef9d74e052fdf147d474c513
BLAKE2b-256 f3ddb9ac41aae1da1ee7e879dae298a98bf0a729105bff2c9b2877778e169900

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for djbackup-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e5ce3c1139b54f16b260a9c8e7a59aea032266b62937ecf27c09ff8b1e08c7e
MD5 7e75ab1d2526aee1d1db52e20e7a0be5
BLAKE2b-256 0ab57bbd01cbdc19ad898f59b844b96ed37e65078d2d504d655299473cf92da3

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