restore: complete the latest full backup task of site id
when creating a full backup, the task is still running and the database dump which is part of the backup, still says it is still running. during restore, we mark the taskId as completed. detection of the task is using the siteId in config (when restoring via backup config) or just blindly setting the last backup task as completed (in manual form fill).
This commit is contained in:
+10
-1
@@ -31,6 +31,7 @@ const appstore = require('./appstore.js'),
|
||||
semver = require('semver'),
|
||||
paths = require('./paths.js'),
|
||||
system = require('./system.js'),
|
||||
tasks = require('./tasks.js'),
|
||||
users = require('./users.js'),
|
||||
tld = require('tldjs'),
|
||||
tokens = require('./tokens.js');
|
||||
@@ -199,6 +200,14 @@ async function restoreTask(backupSite, remotePath, ipv4Config, ipv6Config, optio
|
||||
|
||||
await backupSites.reinitAll();
|
||||
|
||||
// when creating a sql dump during a full backup, the task has not completed yet. we mark it as completed here for the Sites UI to not indicate a crash
|
||||
// siteId can be missing when restoring manually instead of via the backup config
|
||||
const backupTasks = await tasks.list(1, 1, {
|
||||
type: options.siteId ? tasks.TASK_FULL_BACKUP_PREFIX + options.siteId : null,
|
||||
prefix: !options.siteId ? tasks.TASK_FULL_BACKUP_PREFIX : null // guess that the latest full backup was the site that was used
|
||||
});
|
||||
await tasks.setCompleted(backupTasks[0].id, { error: null });
|
||||
|
||||
const location = await dashboard.getLocation(); // load this fresh from after the backup.restore
|
||||
if (!options.skipDnsSetup) {
|
||||
await dns.registerLocations([location], { overwriteDns: true }, (progress) => setProgress('restore', progress.message));
|
||||
@@ -225,7 +234,7 @@ async function restore(backupConfig, remotePath, version, ipv4Config, ipv6Config
|
||||
assert.strictEqual(typeof version, 'string');
|
||||
assert.strictEqual(typeof ipv4Config, 'object');
|
||||
assert.strictEqual(typeof ipv6Config, 'object');
|
||||
assert.strictEqual(typeof options, 'object'); // { skipDnsSetup }
|
||||
assert.strictEqual(typeof options, 'object'); // { skipDnsSetup, siteId }
|
||||
assert.strictEqual(typeof auditSource, 'object');
|
||||
|
||||
if (!semver.valid(version)) throw new BoxError(BoxError.BAD_FIELD, 'version is not a valid semver');
|
||||
|
||||
Reference in New Issue
Block a user