first commit
This commit is contained in:
commit
3c0479faf0
169 files changed
+27617
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import type { HttpContext } from '@adonisjs/core/http'
|
||||
import vpsConfig from '#config/vps'
|
||||
import backupService from '#services/backup_service'
|
||||
import { actor, audit } from '#services/audit'
|
||||
|
||||
export default class BackupsController {
|
||||
async index() {
|
||||
return {
|
||||
dir: vpsConfig.backups.dir,
|
||||
schedule: backupService.schedule,
|
||||
files: await backupService.list(),
|
||||
}
|
||||
}
|
||||
|
||||
async store(ctx: HttpContext) {
|
||||
const job = await backupService.run(actor(ctx))
|
||||
return { jobId: job.id }
|
||||
}
|
||||
|
||||
async download(ctx: HttpContext) {
|
||||
const path = backupService.path(ctx.params.name)
|
||||
await audit(ctx, {
|
||||
action: 'Téléchargement de sauvegarde',
|
||||
target: ctx.params.name,
|
||||
status: 'success',
|
||||
})
|
||||
return ctx.response.attachment(path, ctx.params.name)
|
||||
}
|
||||
|
||||
async destroy(ctx: HttpContext) {
|
||||
await backupService.delete(ctx.params.name)
|
||||
await audit(ctx, {
|
||||
action: 'Suppression de sauvegarde',
|
||||
target: ctx.params.name,
|
||||
status: 'success',
|
||||
})
|
||||
return { ok: true }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user