provision: download mail backup during restore
This commit is contained in:
14
src/mail.js
14
src/mail.js
@@ -69,6 +69,8 @@ exports = module.exports = {
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
backups = require('./backups.js'),
|
||||
backuptask = require('./backuptask.js'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
cloudron = require('./cloudron.js'),
|
||||
constants = require('./constants.js'),
|
||||
@@ -749,6 +751,18 @@ async function restartMail() {
|
||||
async function startMail(existingInfra) {
|
||||
assert.strictEqual(typeof existingInfra, 'object');
|
||||
|
||||
if (existingInfra.version === 'none') {
|
||||
const [error, results] = await safe(backups.getByIdentifierAndStatePaged(backups.BACKUP_IDENTIFIER_MAIL, backups.BACKUP_STATE_NORMAL, 1, 1));
|
||||
if (error || results.length == 0) {
|
||||
debug('startMail: could not find backup to restore', error, results);
|
||||
} else {
|
||||
debug(`startMail: downloading backup ${results[0].id}`);
|
||||
const restoreConfig = { backupId: results[0].id, backupFormat: results[0].format };
|
||||
// have to wait for download before starting mail container because we download as non-root user
|
||||
await backuptask.downloadMail(restoreConfig, (message) => debug(`startMail: ${message}`));
|
||||
}
|
||||
}
|
||||
|
||||
await restartMail();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user