You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

djbackup

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djbackup

djbackup(django backup) is an installable module for Django that is used for backup purposes, specifically for backing up the database and media files.

2.3.1
pipPyPI
Maintainers
1

dj_backup

What is this ?

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

Available at:

  • pypi

  • github

supported databases
  • mysql
  • postgres
  • sqlite
supported storages
  • local
  • sftp server
  • ftp server
  • dropbox
  • 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

from dj_backup.core.utils.static import load_static

STATICFILES_DIRS = [
    ...
    load_static()
]

4. add dj_backup urls to project urls

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

5. set dj_backup basic config to django settings


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

6. migrate & collect static files

    python manage.py migrate
    python manage.py collectstatic

7. run backup!

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

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

Full 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': {
        #     'APP_KEY': '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:

storageinstall command
TELEGRAM_BOTpip install djbackup[telegram]
SFTP_SERVERpip install djbackup[sftpserver]
FTP_SERVERpip install djbackup[ftpserver]
DROPBOXpip install djbackup[dropbox]

- databases:

databaseinstall command
mysqlpip install djbackup[mysql]
postgresqlpip 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

Keywords

django

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts