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:
Girish Ramakrishnan
2025-09-22 17:59:26 +02:00
parent 69d92ba0a8
commit 5157789774
11 changed files with 88 additions and 88 deletions
+12 -8
View File
@@ -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;
}
}
}