backuptask: better debugs

This commit is contained in:
Girish Ramakrishnan
2021-09-26 18:45:23 -07:00
parent 90482f0263
commit 743597f91e
+8 -14
View File
@@ -43,12 +43,6 @@ const apps = require('./apps.js'),
const BACKUP_UPLOAD_CMD = path.join(__dirname, 'scripts/backupupload.js');
const getBackupConfig = util.callbackify(settings.getBackupConfig);
function debugApp(app) {
assert(typeof app === 'object');
debug(app.fqdn + ' ' + util.format.apply(util, Array.prototype.slice.call(arguments, 1)));
}
function canBackupApp(app) {
// only backup apps that are installed or specific pending states
@@ -766,7 +760,7 @@ async function rotateBoxBackup(backupConfig, tag, options, appBackupIds, progres
const backupId = `${tag}/box_v${constants.VERSION}`;
const format = backupConfig.format;
debug(`Rotating box backup to id ${backupId}`);
debug(`rotateBoxBackup: rotating to id ${backupId}`);
const data = {
encryptionVersion: backupConfig.encryption ? 2 : null,
@@ -791,7 +785,7 @@ async function rotateBoxBackup(backupConfig, tag, options, appBackupIds, progres
if (copyBackupError) return reject(copyBackupError);
if (error) return reject(error);
debug(`Rotated box backup successfully as id ${backupId}`);
debug(`rotateBoxBackup: rotated successfully as id ${backupId}`);
resolve(backupId);
});
@@ -827,7 +821,7 @@ async function rotateAppBackup(backupConfig, app, tag, options, progressCallback
const backupId = `${tag}/app_${app.fqdn}_v${manifest.version}`;
const format = backupConfig.format;
debug(`Rotating app backup of ${app.id} to id ${backupId}`);
debug(`rotateAppBackup: rotating ${app.fqdn} to id ${backupId}`);
const data = {
encryptionVersion: backupConfig.encryption ? 2 : null,
@@ -852,7 +846,7 @@ async function rotateAppBackup(backupConfig, app, tag, options, progressCallback
if (copyBackupError) return reject(copyBackupError);
if (error) return reject(error);
debug(`Rotated app backup of ${app.id} successfully to id ${backupId}. Took ${(new Date() - startTime)/1000} seconds`);
debug(`rotateAppBackup: rotated ${app.fqdn} to id ${backupId}. Took ${(new Date() - startTime)/1000} seconds`);
resolve(backupId);
});
@@ -868,7 +862,7 @@ async function backupApp(app, options, progressCallback) {
const tag = (new Date()).toISOString().replace(/[T.]/g, '-').replace(/[:Z]/g,'');
debug(`backupApp - Backing up ${app.fqdn} with tag ${tag}`);
debug(`backupApp: backing up ${app.fqdn} with tag ${tag}`);
await backupAppWithTag(app, tag, options, progressCallback);
}
@@ -883,7 +877,7 @@ async function snapshotApp(app, progressCallback) {
await apps.backupConfig(app);
await services.backupAddons(app, app.manifest.addons);
debugApp(app, `snapshotApp: took ${(new Date() - startTime)/1000} seconds`);
debug(`snapshotApp: ${app.fqdn} took ${(new Date() - startTime)/1000} seconds`);
}
async function uploadAppSnapshot(backupConfig, app, progressCallback) {
@@ -912,7 +906,7 @@ async function uploadAppSnapshot(backupConfig, app, progressCallback) {
await util.promisify(runBackupUpload)(uploadConfig, progressCallback);
debugApp(app, `uploadAppSnapshot: ${backupId} done. ${(new Date() - startTime)/1000} seconds`);
debug(`uploadAppSnapshot: ${app.fqdn} upload with id ${backupId}. ${(new Date() - startTime)/1000} seconds`);
await backups.setSnapshotInfo(app.id, { timestamp: new Date().toISOString(), manifest: app.manifest, format: backupConfig.format });
}
@@ -961,7 +955,7 @@ async function backupBoxAndApps(options, progressCallback) {
const startTime = new Date();
const backupId = await backupAppWithTag(app, tag, options, (progress) => progressCallback({ percent: percent, message: progress.message }));
debugApp(app, `Backed up. Took ${(new Date() - startTime)/1000} seconds`);
debug(`backupBoxAndApps: app ${app.fqdn} backup finished. Took ${(new Date() - startTime)/1000} seconds`);
if (backupId) appBackupIds.push(backupId); // backupId can be null if in BAD_STATE and never backed up
}