From b08cd8da20c66ca5494cc435a745389afd3ab927 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 25 Apr 2021 12:14:36 +1000 Subject: [PATCH] Remove dbbackup integration - Data dumping and restoring is now very complex! - We should use the invoke export-records function now, rather than relying on dbbackup / dbrestore - Documentation will be updated to match --- InvenTree/InvenTree/ready.py | 2 -- InvenTree/InvenTree/settings.py | 12 ------------ InvenTree/config_template.yaml | 8 +------- docker/Dockerfile | 1 - docker/start_dev_server.sh | 5 ----- docker/start_prod_server.sh | 5 ----- requirements.txt | 1 - tasks.py | 21 --------------------- 8 files changed, 1 insertion(+), 54 deletions(-) diff --git a/InvenTree/InvenTree/ready.py b/InvenTree/InvenTree/ready.py index 6facedd6ff..f78c7ad493 100644 --- a/InvenTree/InvenTree/ready.py +++ b/InvenTree/InvenTree/ready.py @@ -18,8 +18,6 @@ def canAppAccessDatabase(): 'makemirations', 'migrate', 'check', - 'dbbackup', - 'mediabackup', 'dbrestore', 'mediarestore', 'shell', diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 596dbd29c8..8d9012b762 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -250,7 +250,6 @@ INSTALLED_APPS = [ # Third part add-ons 'django_filters', # Extended filter functionality - 'dbbackup', # Database backup / restore 'rest_framework', # DRF (Django Rest Framework) 'rest_framework.authtoken', # Token authentication for API 'corsheaders', # Cross-origin Resource Sharing for DRF @@ -586,17 +585,6 @@ CRISPY_TEMPLATE_PACK = 'bootstrap3' # Use database transactions when importing / exporting data IMPORT_EXPORT_USE_TRANSACTIONS = True -BACKUP_DIR = get_setting( - 'INVENTREE_BACKUP_DIR', - CONFIG.get('backup_dir', tempfile.gettempdir()), -) - -# Settings for dbbsettings app -DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage' -DBBACKUP_STORAGE_OPTIONS = { - 'location': BACKUP_DIR, -} - # Internal IP addresses allowed to see the debug toolbar INTERNAL_IPS = [ '127.0.0.1', diff --git a/InvenTree/config_template.yaml b/InvenTree/config_template.yaml index 0a86d88827..de09e37e4f 100644 --- a/InvenTree/config_template.yaml +++ b/InvenTree/config_template.yaml @@ -138,12 +138,6 @@ static_root: '/home/inventree/static' # - git # - ssh -# Backup options -# Set the backup_dir parameter to store backup files in a specific location -# If unspecified, the local user's temp directory will be used -# Use environment variable INVENTREE_BACKUP_DIR -backup_dir: '/home/inventree/data/backup/' - # Permit custom authentication backends #authentication_backends: # - 'django.contrib.auth.backends.ModelBackend' @@ -159,4 +153,4 @@ backup_dir: '/home/inventree/data/backup/' # - 'django.contrib.auth.middleware.AuthenticationMiddleware' # - 'django.contrib.messages.middleware.MessageMiddleware' # - 'django.middleware.clickjacking.XFrameOptionsMiddleware' -# - 'InvenTree.middleware.AuthRequiredMiddleware' \ No newline at end of file +# - 'InvenTree.middleware.AuthRequiredMiddleware' diff --git a/docker/Dockerfile b/docker/Dockerfile index ab4dbba6b5..c95c2867df 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -21,7 +21,6 @@ ENV INVENTREE_MNG_DIR="${INVENTREE_SRC_DIR}/InvenTree" ENV INVENTREE_DATA_DIR="${INVENTREE_HOME}/data" ENV INVENTREE_STATIC_ROOT="${INVENTREE_HOME}/static" ENV INVENTREE_MEDIA_ROOT="${INVENTREE_DATA_DIR}/media" -ENV INVENTREE_BACKUP_DIR="${INVENTREE_DATA_DIR}/backup" ENV INVENTREE_CONFIG_FILE="${INVENTREE_DATA_DIR}/config.yaml" ENV INVENTREE_SECRET_KEY_FILE="${INVENTREE_DATA_DIR}/secret_key.txt" diff --git a/docker/start_dev_server.sh b/docker/start_dev_server.sh index 481da3c31a..c22805b90b 100644 --- a/docker/start_dev_server.sh +++ b/docker/start_dev_server.sh @@ -11,11 +11,6 @@ if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then mkdir $INVENTREE_MEDIA_ROOT fi -if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then - echo "Creating directory $INVENTREE_BACKUP_DIR" - mkdir $INVENTREE_BACKUP_DIR -fi - # Check if "config.yaml" has been copied into the correct location if test -f "$INVENTREE_CONFIG_FILE"; then echo "$INVENTREE_CONFIG_FILE exists - skipping" diff --git a/docker/start_prod_server.sh b/docker/start_prod_server.sh index 811e189d13..2767e844d6 100644 --- a/docker/start_prod_server.sh +++ b/docker/start_prod_server.sh @@ -11,11 +11,6 @@ if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then mkdir $INVENTREE_MEDIA_ROOT fi -if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then - echo "Creating directory $INVENTREE_BACKUP_DIR" - mkdir $INVENTREE_BACKUP_DIR -fi - # Check if "config.yaml" has been copied into the correct location if test -f "$INVENTREE_CONFIG_FILE"; then echo "$INVENTREE_CONFIG_FILE exists - skipping" diff --git a/requirements.txt b/requirements.txt index 1392531e29..3291574084 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ wheel>=0.34.2 # Wheel Django==3.2 # Django package pillow==8.1.1 # Image manipulation djangorestframework==3.12.4 # DRF framework -django-dbbackup==3.3.0 # Database backup / restore functionality django-cors-headers==3.2.0 # CORS headers extension for DRF django-filter==2.4.0 # Extended filtering options django-mptt==0.11.0 # Modified Preorder Tree Traversal diff --git a/tasks.py b/tasks.py index 0d2f820bea..c4eda5e5bf 100644 --- a/tasks.py +++ b/tasks.py @@ -401,27 +401,6 @@ def import_fixtures(c): manage(c, command, pty=True) -@task -def backup(c): - """ - Create a backup of database models and uploaded media files. - - Backup files will be written to the 'backup_dir' file specified in 'config.yaml' - """ - - manage(c, 'dbbackup') - manage(c, 'mediabackup') - -@task -def restore(c): - """ - Restores database models and media files. - - Backup files are read from the 'backup_dir' file specified in 'config.yaml' - """ - - manage(c, 'dbrestore') - manage(c, 'mediarestore') @task(help={'address': 'Server address:port (default=127.0.0.1:8000)'}) def server(c, address="127.0.0.1:8000"):