Add scheduled database backup system automation
This commit is contained in:
parent
2ef0c75a25
commit
b1cb9f9964
2 changed files with 8 additions and 1 deletions
|
|
@ -91,6 +91,13 @@ SYSTEM_AUTOMATIONS = [
|
|||
'action_type': 'deep_scan_library',
|
||||
'initial_delay': 900, # 15 min after startup
|
||||
},
|
||||
{
|
||||
'name': 'Auto-Backup Database',
|
||||
'trigger_type': 'schedule',
|
||||
'trigger_config': {'interval': 3, 'unit': 'days'},
|
||||
'action_type': 'backup_database',
|
||||
'initial_delay': 600, # 10 min after startup
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -856,7 +856,7 @@ def _register_automation_handlers():
|
|||
db_path = os.environ.get('DATABASE_PATH', 'database/music_library.db')
|
||||
if not os.path.exists(db_path):
|
||||
return {'status': 'error', 'reason': 'Database file not found'}
|
||||
max_backups = 3
|
||||
max_backups = 5
|
||||
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
||||
backup_path = f"{db_path}.backup_{timestamp}"
|
||||
# Use SQLite backup API for safe hot-copy of active database
|
||||
|
|
|
|||
Loading…
Reference in a new issue