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.1.tar.gz (22.5 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.1-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: djbackup-2.0.1.tar.gz
  • Upload date:
  • Size: 22.5 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.1.tar.gz
Algorithm Hash digest
SHA256 a9ed77fb7e0b814c08c2db4a0095dbf7770c227792cda67bc25d7041b2552f65
MD5 4380f039526df781c863900a9a76db48
BLAKE2b-256 8f0ae5d69a2fc179d65fb69a5fe842b4b0abc854484429dac48ad3cbaf1d087d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: djbackup-2.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 691184b9ecfb548e52645ba1f833159b1c2dca91ca1a253bd921b9e9e2a70ea3
MD5 19d1249db814d93314e06422dc93a10f
BLAKE2b-256 16aeb1120e88e4c7365ec253af708f42d9595858ba40997987c2ece2cdd7a8c3

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