mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Configuration options for dbbackup (#4190)
* Configuration options for dbbackup Ref: https://github.com/inventree/InvenTree/discussions/4179 * DBBACKUP_SEND_EMAIL is always False * Cleanup settings file * Make backup step optional during update * Change update operation to perform backup by default
This commit is contained in:
parent
ee2290da28
commit
385ed8277d
@ -147,10 +147,21 @@ STATIC_COLOR_THEMES_DIR = STATIC_ROOT.joinpath('css', 'color-themes').resolve()
|
|||||||
# Web URL endpoint for served media files
|
# Web URL endpoint for served media files
|
||||||
MEDIA_URL = '/media/'
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
# Backup directories
|
# Database backup options
|
||||||
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
|
# Ref: https://django-dbbackup.readthedocs.io/en/master/configuration.html
|
||||||
DBBACKUP_STORAGE_OPTIONS = {'location': config.get_backup_dir()}
|
|
||||||
DBBACKUP_SEND_EMAIL = False
|
DBBACKUP_SEND_EMAIL = False
|
||||||
|
DBBACKUP_STORAGE = get_setting(
|
||||||
|
'INVENTREE_BACKUP_STORAGE',
|
||||||
|
'backup_storage',
|
||||||
|
'django.core.files.storage.FileSystemStorage'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Default backup configuration
|
||||||
|
DBBACKUP_STORAGE_OPTIONS = get_setting('INVENTREE_BACKUP_OPTIONS', 'backup_options', None)
|
||||||
|
if DBBACKUP_STORAGE_OPTIONS is None:
|
||||||
|
DBBACKUP_STORAGE_OPTIONS = {
|
||||||
|
'location': config.get_backup_dir(),
|
||||||
|
}
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
@ -142,8 +142,11 @@ cors:
|
|||||||
# STATIC_ROOT is the local filesystem location for storing static files
|
# STATIC_ROOT is the local filesystem location for storing static files
|
||||||
#static_root: '/home/inventree/data/static'
|
#static_root: '/home/inventree/data/static'
|
||||||
|
|
||||||
# BACKUP_DIR is the local filesystem location for storing backups
|
### Backup configuration options ###
|
||||||
|
# INVENTREE_BACKUP_DIR is the local filesystem location for storing backups
|
||||||
|
backup_storage: django.core.files.storage.FileSystemStorage
|
||||||
#backup_dir: '/home/inventree/data/backup'
|
#backup_dir: '/home/inventree/data/backup'
|
||||||
|
#backup_options:
|
||||||
|
|
||||||
# Background worker options
|
# Background worker options
|
||||||
background:
|
background:
|
||||||
|
35
tasks.py
35
tasks.py
@ -180,6 +180,14 @@ def translate_stats(c):
|
|||||||
|
|
||||||
The file generated from this is needed for the UI.
|
The file generated from this is needed for the UI.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Recompile the translation files (.mo)
|
||||||
|
# We do not run 'invoke translate' here, as that will touch the source (.po) files too!
|
||||||
|
try:
|
||||||
|
manage(c, 'compilemessages', pty=True)
|
||||||
|
except Exception:
|
||||||
|
print("WARNING: Translation files could not be compiled:")
|
||||||
|
|
||||||
path = Path('InvenTree', 'script', 'translation_stats.py')
|
path = Path('InvenTree', 'script', 'translation_stats.py')
|
||||||
c.run(f'python3 {path}')
|
c.run(f'python3 {path}')
|
||||||
|
|
||||||
@ -216,7 +224,7 @@ def restore(c):
|
|||||||
manage(c, "mediarestore --noinput --uncompress")
|
manage(c, "mediarestore --noinput --uncompress")
|
||||||
|
|
||||||
|
|
||||||
@task(pre=[backup, ], post=[rebuild_models, rebuild_thumbnails])
|
@task(post=[rebuild_models, rebuild_thumbnails])
|
||||||
def migrate(c):
|
def migrate(c):
|
||||||
"""Performs database migrations.
|
"""Performs database migrations.
|
||||||
|
|
||||||
@ -234,8 +242,13 @@ def migrate(c):
|
|||||||
print("InvenTree database migrations completed!")
|
print("InvenTree database migrations completed!")
|
||||||
|
|
||||||
|
|
||||||
@task(pre=[install, migrate, static, clean_settings, translate_stats])
|
@task(
|
||||||
def update(c):
|
post=[static, clean_settings, translate_stats],
|
||||||
|
help={
|
||||||
|
'skip_backup': 'Skip database backup step (advanced users)'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def update(c, skip_backup=False):
|
||||||
"""Update InvenTree installation.
|
"""Update InvenTree installation.
|
||||||
|
|
||||||
This command should be invoked after source code has been updated,
|
This command should be invoked after source code has been updated,
|
||||||
@ -244,17 +257,21 @@ def update(c):
|
|||||||
The following tasks are performed, in order:
|
The following tasks are performed, in order:
|
||||||
|
|
||||||
- install
|
- install
|
||||||
|
- backup (optional)
|
||||||
- migrate
|
- migrate
|
||||||
- static
|
- static
|
||||||
- clean_settings
|
- clean_settings
|
||||||
- translate_stats
|
- translate_stats
|
||||||
"""
|
"""
|
||||||
# Recompile the translation files (.mo)
|
|
||||||
# We do not run 'invoke translate' here, as that will touch the source (.po) files too!
|
# Ensure required components are installed
|
||||||
try:
|
install(c)
|
||||||
manage(c, 'compilemessages', pty=True)
|
|
||||||
except Exception:
|
if not skip_backup:
|
||||||
print("WARNING: Translation files could not be compiled:")
|
backup(c)
|
||||||
|
|
||||||
|
# Perform database migrations
|
||||||
|
migrate(c)
|
||||||
|
|
||||||
|
|
||||||
# Data tasks
|
# Data tasks
|
||||||
|
Loading…
Reference in New Issue
Block a user