Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
feat: add servers backup only
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Apr 24, 2020
1 parent 07a89fd commit b621f12
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/pages/admin/operations/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,27 @@ app.get('/admin/operations/backup', (req: Request, res: Response, next: NextFunc
];
res.redirect('/admin/');
});

app.get('/admin/operations/backup-servers', (req: Request, res: Response, next: NextFunction) => {
MonitoringServer.findAll().then((models: [MonitoringServerModel[]]) => {
const backupDate = new Date().toISOString();
const attachements: Attachment[] = [
{
filename: 'servers.json',
content: JSON.stringify(models[0]),
contentType: 'application/json',
},
];
EmailQueue.sendBackupEmail(
'Here is your backup.\nCreated at: ' + backupDate + '\nServers: ' + models[0].length + '\n\n',
attachements
);
});
req.session!.messages = [
{
message: 'The backup will be send to you by email.',
level: 'success',
},
];
res.redirect('/admin/');
});
1 change: 1 addition & 0 deletions templates/pages/admin/operations/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<a href="/admin/operations/sendsms">Envoyer un sms de test</a><br/>
<a href="/admin/operations/sendemail">Envoyer un email de test</a><br/>
<a href="/admin/operations/backup">Envoyer une backup des données</a>
<a href="/admin/operations/backup-servers">Envoyer une backup des serveurs sans les statistiques</a>
</div>
{% endblock %}

0 comments on commit b621f12

Please sign in to comment.