backups: add per site enabledForUpdates flag
previously, we had a singleton 'main' flag to indicate a site can be used for updates. with this new approach, we can get rid of the 'primary' concept. each site can be used for updates or not.
This commit is contained in:
+12
-8
@@ -566,14 +566,18 @@ async function updateCommand(app, args, progressCallback) {
|
||||
|
||||
if (!updateConfig.skipBackup) {
|
||||
await progressCallback({ percent: 15, message: 'Backing up app' });
|
||||
const backupSite = await backupSites.getPrimary();
|
||||
// preserve update backups for 3 weeks
|
||||
const [error] = await safe(backuptask.backupApp(app, backupSite, { preserveSecs: 3*7*24*60*60 }, (progress) => {
|
||||
progressCallback({ percent: 15, message: `Backup - ${progress.message}` });
|
||||
}));
|
||||
if (error) {
|
||||
error.backupError = true;
|
||||
throw error;
|
||||
const sites = await backupSites.listByContentForUpdates(app.id);
|
||||
if (sites.length === 0) throw new BoxError(BoxError.BAD_STATE, 'App has no backup site for updates', { backupError: true });
|
||||
|
||||
for (const site of sites) {
|
||||
// preserve update backups for 3 weeks
|
||||
const [error] = await safe(backuptask.backupApp(app, site, { preserveSecs: 3*7*24*60*60 }, (progress) => {
|
||||
progressCallback({ percent: 15, message: `Backup - ${progress.message}` });
|
||||
}));
|
||||
if (error) {
|
||||
error.backupError = true;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user