Metadata-Version: 2.1
Name: djbackup
Version: 2.1.0
Summary: dj_backup is an installable module for Django that is used for backup purposes.
Home-page: https://github.com/FZl47/dj_backup
Author: FZl47
Author-email: fzl8747@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: APScheduler ==3.11.0
Requires-Dist: asgiref ==3.8.1
Requires-Dist: Django ==5.2.1
Requires-Dist: django-model-utils ==5.0.0
Requires-Dist: sqlparse ==0.5.3
Requires-Dist: tzdata ==2025.2
Requires-Dist: tzlocal ==5.3.1
Provides-Extra: all
Requires-Dist: python-telegram-bot ; extra == 'all'
Requires-Dist: paramiko ; extra == 'all'
Requires-Dist: ftplib ; extra == 'all'
Requires-Dist: dropbox ; extra == 'all'
Requires-Dist: mysqlclient ; extra == 'all'
Requires-Dist: psycopg2 ; extra == 'all'
Provides-Extra: dropbox
Requires-Dist: dropbox ; extra == 'dropbox'
Provides-Extra: ftpserver
Requires-Dist: ftplib ; extra == 'ftpserver'
Provides-Extra: mysql
Requires-Dist: mysqlclient ; extra == 'mysql'
Provides-Extra: postgresql
Requires-Dist: psycopg2 ; extra == 'postgresql'
Provides-Extra: sftpserver
Requires-Dist: paramiko ; extra == 'sftpserver'
Provides-Extra: telegram
Requires-Dist: python-telegram-bot ; extra == 'telegram'

# dj_backup

## What is this ?

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

### Available at:
- #### <a href="https://pypi.org/project/djbackup/">pypi</a>
- #### <a href="https://github.com/FZl47/dj_backup">github</a>


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

```sh
    pip install djbackup
```
OR
- #### for using all features
```sh
    pip install djbackup[all]
```

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

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

#### 3. add static files dir path to django

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

```

#### 4. add locale file to django(`optional`)

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

#### 5. add dj_backup urls to project urls

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

#### 6. set dj_backup <span style="text-decoration: underline;">basic config</span> to django settings

```python

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

```

#### 7. migrate & collect static files

```python
    python manage.py migrate
```

```python
    python manage.py collectstatic
```

#### 8. run backup!

- command is for managing settings and executing backup tasks

```python
    python manage.py run-backup
```

### 9. run django

```python
    python manage.py runserver
```

- OR use wsgi/asgi handler like: (uwsgi, gunicorn, waitress or etc)

### Dashboard

#### now you can access to `dj_backup` dashboard

```djangourlpath
    127.0.0.1:8000/dj-backup/
```

OR

```djangourlpath
    xxx.xxx:xxxx/dj-backup/  
```

### Additional Config

```python
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/'
        # }
    }
}
```

- ### <span style="text-decoration: underline;line-height:50px;">To use storage providers or perform database backups, you need to install the appropriate packages according to your needs using the commands below</span>

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


