Simply remove all backups up to the last to when using filesystem

backend
This commit is contained in:
Johannes Zellner
2016-10-11 10:04:29 +02:00
parent 2d39a9bfa1
commit d7ea06e80e
2 changed files with 3 additions and 5 deletions
+2 -4
View File
@@ -121,10 +121,8 @@ function cleanupBackups(callback) {
backups.getPaged(1, 1000, function (error, result) {
if (error) return callback(error);
var TIME_OFFSET = 1000 * 60 * 60 * 24 * 2; // 2 days = 2 backups
var TIME_THRESHOLD = Date.now() - TIME_OFFSET;
var toCleanup = result.filter(function (backup) { return backup.creationTime.getTime() <= TIME_THRESHOLD; });
// sort with latest backups first in the array and slice 2
var toCleanup = result.sort(function (a, b) { return b.creationTime.getTime() - a.creationTime.getTime(); }).slice(2);
debug('cleanupBackups: about to clean: ', toCleanup);