backup site: add contents
it is a json that can be one of the three: * null - include everything * include - only include these ids * exclude - everything except these ids
This commit is contained in:
@@ -493,6 +493,24 @@ async function downloadMail(backupSite, remotePath, progressCallback) {
|
||||
debug('downloadMail: time: %s', (new Date() - startTime)/1000);
|
||||
}
|
||||
|
||||
function shouldBackup(backupSite, id) {
|
||||
if (!backupSite.contents) return true;
|
||||
|
||||
const { include, exclude } = backupSite;
|
||||
|
||||
if (include && !include.includes(id)) {
|
||||
debug(`fullBackup: skipped backup of ${id} since it is not included`);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (exclude?.includes(id)) {
|
||||
debug(`fullBackup: skipped backup of ${id} since it is not included`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// this function is called from external process. calling process is expected to have a lock
|
||||
async function fullBackup(backupSiteId, options, progressCallback) {
|
||||
assert.strictEqual(typeof backupSiteId, 'string');
|
||||
@@ -518,6 +536,7 @@ async function fullBackup(backupSiteId, options, progressCallback) {
|
||||
debug(`fullBackup: skipped backup ${app.fqdn} (${i+1}/${allApps.length}) since automatic backup disabled`);
|
||||
continue; // nothing to backup
|
||||
}
|
||||
if (!shouldBackup(backupSite, app.id)) continue;
|
||||
|
||||
progressCallback({ percent, message: `Backing up ${app.fqdn} (${i+1}/${allApps.length}). Waiting for lock` });
|
||||
await locks.wait(`${locks.TYPE_APP_BACKUP_PREFIX}${app.id}`);
|
||||
@@ -529,6 +548,8 @@ async function fullBackup(backupSiteId, options, progressCallback) {
|
||||
if (appBackupId) appBackupIds.push(appBackupId); // backupId can be null if in BAD_STATE and never backed up
|
||||
}
|
||||
|
||||
if (!shouldBackup(backupSite, 'mail+platform')) return appBackupIds;
|
||||
|
||||
progressCallback({ percent, message: 'Backing up mail' });
|
||||
percent += step;
|
||||
const mailBackupId = await backupMailWithTag(backupSite, tag, options, (progress) => progressCallback({ percent, message: progress.message }));
|
||||
|
||||
Reference in New Issue
Block a user