feat: "Fazer backup agora" in Integrações
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 4m40s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 1m29s
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 4m40s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 1m29s
The backup row gets a button that asks for a backup outside the daily hour, for after a failure or before a risky change. The Kanban records the request; the backup service, which alone may read the whole database, looks every minute and runs it. The row says it was asked for until it runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -80,10 +80,23 @@ def backup_status(c):
|
||||
"""The latest database backup and the latest run, which may have failed."""
|
||||
ok = c.execute('''SELECT finished_at,bytes FROM dtf_local.backups WHERE status='ok'
|
||||
ORDER BY finished_at DESC LIMIT 1''').fetchone()
|
||||
last = c.execute('SELECT finished_at,status,detail FROM dtf_local.backups ORDER BY finished_at DESC LIMIT 1').fetchone()
|
||||
last = c.execute('SELECT started_at,finished_at,status,detail FROM dtf_local.backups ORDER BY finished_at DESC LIMIT 1').fetchone()
|
||||
asked = c.execute('''SELECT 1 FROM dtf_local.backup_requests WHERE requested_at>%s LIMIT 1''',
|
||||
(last['started_at'] if last else datetime(2000, 1, 1, tzinfo=timezone.utc),)).fetchone()
|
||||
return {'last_ok': ok['finished_at'].isoformat() if ok else None, 'bytes': ok['bytes'] if ok else None,
|
||||
'failed': last['detail'] if last and last['status'] == 'failed' else None,
|
||||
'failed_at': last['finished_at'].isoformat() if last and last['status'] == 'failed' else None}
|
||||
'failed_at': last['finished_at'].isoformat() if last and last['status'] == 'failed' else None,
|
||||
'requested': asked is not None}
|
||||
|
||||
|
||||
@router.post('/api/operator/backup/run')
|
||||
def backup_now(user=Depends(can('manage'))):
|
||||
"""A backup now, outside the daily hour: the backup service, which alone
|
||||
may read the whole database, starts it within a minute."""
|
||||
with db.connect() as c:
|
||||
c.execute('INSERT INTO dtf_local.backup_requests(requested_by) VALUES(%s)', (user,))
|
||||
audit('backup_requested', operator=user)
|
||||
return {'ok': True}
|
||||
|
||||
|
||||
@router.get('/api/operator/board')
|
||||
|
||||
Reference in New Issue
Block a user