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

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:
Cauê Faleiros
2026-10-16 17:09:00 -03:00
parent bd718796c5
commit 6919383d37
6 changed files with 64 additions and 6 deletions

View File

@@ -1679,9 +1679,14 @@ function renderIntegrations(){
const ontem=bk.last_ok&&Date.now()-new Date(bk.last_ok)<26*3600e3;
const tam=bk.bytes?(bk.bytes<1048576?Math.max(1,Math.round(bk.bytes/1024))+' KB':(bk.bytes/1048576).toFixed(1).replace('.',',')+' MB'):'';
const never=!bk.last_ok&&!bk.failed;
const now=may('manage')&&!never?[button(bk.requested?'Pedido…':'Fazer backup agora',async()=>{
try{await api('/backup/run',{});say('Backup pedido: começa em até 1 minuto. Atualize para ver o resultado.');await load();}
catch(e){say(e.message,true);}},'btn small')]:[];
if(bk.requested&&now[0])now[0].disabled=true;
rows.push(integration({name:'Backup do banco',state:never?'Não configurado':ontem&&!bk.failed?'Em dia':'Verificar',
tone:never?'off':ontem&&!bk.failed?'ok':'warn',
summary:bk.failed?'A última tentativa falhou ('+when(bk.failed_at)+').':bk.last_ok?'Último em '+when(bk.last_ok)+(tam?' · '+tam:''):'Nenhum backup feito ainda.',
tone:never?'off':ontem&&!bk.failed?'ok':'warn',actions:now,
summary:bk.requested?'Backup pedido · começa em até 1 minuto.':
bk.failed?'A última tentativa falhou ('+when(bk.failed_at)+').':bk.last_ok?'Último em '+when(bk.last_ok)+(tam?' · '+tam:''):'Nenhum backup feito ainda.',
details:[...(bk.last_ok?[['Último backup',when(bk.last_ok)+(tam?' · '+tam:'')]]:[]),...(bk.failed?[['Erro',bk.failed]]:[]),
node('p','Cópia diária, criptografada, fora do servidor.')]}));
$('integrations').replaceChildren(...rows);