Add backup cleanup eventlog

This commit is contained in:
Girish Ramakrishnan
2017-10-01 09:29:42 -07:00
parent e089851ae9
commit f9973e765c
6 changed files with 13 additions and 6 deletions
+7 -3
View File
@@ -845,8 +845,9 @@ function cleanupAppBackups(backupConfig, referencedAppBackups, callback) {
});
}
function cleanupBoxBackups(backupConfig, callback) {
function cleanupBoxBackups(backupConfig, auditSource, callback) {
assert.strictEqual(typeof backupConfig, 'object');
assert.strictEqual(typeof auditSource, 'object');
assert.strictEqual(typeof callback, 'function');
const now = new Date();
@@ -893,6 +894,8 @@ function cleanupBoxBackups(backupConfig, callback) {
api(backupConfig.provider).remove(backupConfig, path.dirname(filePaths[0]), function (error) {
if (error) debug('cleanupBoxBackups: unable to prune directory %s : %s', path.dirname(filePaths[0]), error.message);
eventlog.add(eventlog.ACTION_BACKUP_CLEANUP, auditSource, { backup: backup });
backupdb.del(backup.id, function (error) {
if (error) debug('cleanupBoxBackups: error removing from database', error);
else debug('cleanupBoxBackups: removed %j', filePaths);
@@ -951,7 +954,8 @@ function cleanupSnapshots(backupConfig, callback) {
});
}
function cleanup(callback) {
function cleanup(auditSource, callback) {
assert.strictEqual(typeof auditSource, 'object');
assert(!callback || typeof callback === 'function'); // callback is null when called from cronjob
callback = callback || NOOP_CALLBACK;
@@ -964,7 +968,7 @@ function cleanup(callback) {
return callback();
}
cleanupBoxBackups(backupConfig, function (error, referencedAppBackups) {
cleanupBoxBackups(backupConfig, auditSource, function (error, referencedAppBackups) {
if (error) return callback(error);
cleanupAppBackups(backupConfig, referencedAppBackups, function (error) {