Metadata-Version: 2.1
Name: djbackup
Version: 2.0.3
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: ansicon ==1.89.0
Requires-Dist: arrow ==1.3.0
Requires-Dist: asgiref ==3.7.2
Requires-Dist: bcrypt ==4.2.0
Requires-Dist: blessed ==1.20.0
Requires-Dist: certifi ==2024.7.4
Requires-Dist: charset-normalizer ==3.3.2
Requires-Dist: cryptography ==43.0.0
Requires-Dist: decorator ==5.2.1
Requires-Dist: django-model-utils ==5.0.0
Requires-Dist: django-picklefield ==3.1
Requires-Dist: django-q ==1.3.9
Requires-Dist: dropbox ==12.0.2
Requires-Dist: idna ==3.7
Requires-Dist: jinxed ==1.2.1
Requires-Dist: mysqlclient ==2.2.4
Requires-Dist: paramiko ==3.4.0
Requires-Dist: ply ==3.11
Requires-Dist: psycopg2 ==2.9.9
Requires-Dist: pycparser ==2.22
Requires-Dist: PyNaCl ==1.5.0
Requires-Dist: python-dateutil ==2.8.2
Requires-Dist: python-telegram-bot ==13.0
Requires-Dist: pytz ==2025.2
Requires-Dist: requests ==2.32.3
Requires-Dist: schedule ==1.2.1
Requires-Dist: six ==1.16.0
Requires-Dist: sqlparse ==0.4.4
Requires-Dist: stone ==3.3.1
Requires-Dist: tornado ==6.4.2
Requires-Dist: types-python-dateutil ==2.8.19.20240106
Requires-Dist: typing-extensions ==4.9.0
Requires-Dist: tzdata ==2023.4
Requires-Dist: tzlocal ==5.3.1
Requires-Dist: urllib3 ==2.2.2
Requires-Dist: wcwidth ==0.2.13

# 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

```sh
    pip install djbackup
```

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

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

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 config to django settings

```python
    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
    python manage.py migrate
```

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

### 8. run backup!

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

### 9. Dashboard

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

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

OR

```djangourlpath
    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


