Add settings for backups (#3806)

Fixes #3794
This commit is contained in:
Matthias Mair 2022-10-18 03:38:57 +02:00 committed by GitHub
parent 3bd64e9098
commit 3956a45c48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 2 deletions

View File

@ -275,8 +275,11 @@ def update_exchange_rates():
def run_backup():
"""Run the backup command."""
call_command("dbbackup", noinput=True, clean=True, compress=True, interactive=False)
call_command("mediabackup", noinput=True, clean=True, compress=True, interactive=False)
from common.models import InvenTreeSetting
if InvenTreeSetting.get_setting('INVENTREE_BACKUP_ENABLE'):
call_command("dbbackup", noinput=True, clean=True, compress=True, interactive=False)
call_command("mediabackup", noinput=True, clean=True, compress=True, interactive=False)
def send_email(subject, body, recipients, from_email=None, html_message=None):

View File

@ -886,6 +886,13 @@ class InvenTreeSetting(BaseInvenTreeSetting):
]
},
'INVENTREE_BACKUP_ENABLE': {
'name': _('Automatic Backup'),
'description': _('Enable automatic backup of database and media files'),
'validator': bool,
'default': True,
},
'BARCODE_ENABLE': {
'name': _('Barcode Support'),
'description': _('Enable barcode scanner support'),

View File

@ -23,6 +23,7 @@
{% include "InvenTree/settings/setting.html" with key="INVENTREE_DOWNLOAD_IMAGE_MAX_SIZE" icon="fa-server" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_REQUIRE_CONFIRM" icon="fa-check" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_TREE_DEPTH" icon="fa-sitemap" %}
{% include "InvenTree/settings/setting.html" with key="INVENTREE_BACKUP_ENABLE" icon="fa-hdd" %}
</tbody>
</table>