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
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
# Backup directories
|
||||
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
|
||||
DBBACKUP_STORAGE_OPTIONS = {'location': config.get_backup_dir()}
|
||||
# Database backup options
|
||||
# Ref: https://django-dbbackup.readthedocs.io/en/master/configuration.html
|
||||
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
|
||||
|
||||
|
@ -142,8 +142,11 @@ cors:
|
||||
# STATIC_ROOT is the local filesystem location for storing static files
|
||||
#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_options:
|
||||
|
||||
# Background worker options
|
||||
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.
|
||||
"""
|
||||
|
||||
# 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')
|
||||
c.run(f'python3 {path}')
|
||||
|
||||
@ -216,7 +224,7 @@ def restore(c):
|
||||
manage(c, "mediarestore --noinput --uncompress")
|
||||
|
||||
|
||||
@task(pre=[backup, ], post=[rebuild_models, rebuild_thumbnails])
|
||||
@task(post=[rebuild_models, rebuild_thumbnails])
|
||||
def migrate(c):
|
||||
"""Performs database migrations.
|
||||
|
||||
@ -234,8 +242,13 @@ def migrate(c):
|
||||
print("InvenTree database migrations completed!")
|
||||
|
||||
|
||||
@task(pre=[install, migrate, static, clean_settings, translate_stats])
|
||||
def update(c):
|
||||
@task(
|
||||
post=[static, clean_settings, translate_stats],
|
||||
help={
|
||||
'skip_backup': 'Skip database backup step (advanced users)'
|
||||
}
|
||||
)
|
||||
def update(c, skip_backup=False):
|
||||
"""Update InvenTree installation.
|
||||
|
||||
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:
|
||||
|
||||
- install
|
||||
- backup (optional)
|
||||
- migrate
|
||||
- static
|
||||
- clean_settings
|
||||
- translate_stats
|
||||
"""
|
||||
# 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:")
|
||||
|
||||
# Ensure required components are installed
|
||||
install(c)
|
||||
|
||||
if not skip_backup:
|
||||
backup(c)
|
||||
|
||||
# Perform database migrations
|
||||
migrate(c)
|
||||
|
||||
|
||||
# Data tasks
|
||||
|
Loading…
Reference in New Issue
Block a user