+6
-2
@@ -35,8 +35,9 @@ var addons = require('./addons.js'),
|
||||
DatabaseError = require('./databaseerror.js'),
|
||||
debug = require('debug')('box:backups'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
locker = require('./locker.js'),
|
||||
filesystem = require('./storage/filesystem.js'),
|
||||
locker = require('./locker.js'),
|
||||
mailer = require('./mailer.js'),
|
||||
path = require('path'),
|
||||
paths = require('./paths.js'),
|
||||
progress = require('./progress.js'),
|
||||
@@ -418,7 +419,10 @@ function backup(auditSource, callback) {
|
||||
progress.set(progress.BACKUP, 0, 'Starting'); // ensure tools can 'wait' on progress
|
||||
|
||||
backupBoxAndApps(auditSource, function (error) { // start the backup operation in the background
|
||||
if (error) debug('backup failed.', error);
|
||||
if (error) {
|
||||
debug('backup failed.', error);
|
||||
mailer.backupFailed(JSON.stringify(error));
|
||||
}
|
||||
|
||||
locker.unlock(locker.OP_FULL_BACKUP);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<%if (format === 'text') { %>
|
||||
|
||||
Dear Cloudron Team,
|
||||
|
||||
Backup of <%= fqdn %> failed.
|
||||
|
||||
Thank you,
|
||||
Your Cloudron
|
||||
|
||||
-------------------------------------
|
||||
|
||||
<%- message %>
|
||||
|
||||
<% } else { %>
|
||||
|
||||
<% } %>
|
||||
|
||||
@@ -17,6 +17,7 @@ exports = module.exports = {
|
||||
appDied: appDied,
|
||||
|
||||
outOfDiskSpace: outOfDiskSpace,
|
||||
backupFailed: backupFailed,
|
||||
|
||||
certificateRenewalError: certificateRenewalError,
|
||||
|
||||
@@ -438,6 +439,21 @@ function outOfDiskSpace(message) {
|
||||
});
|
||||
}
|
||||
|
||||
function backupFailed(message) {
|
||||
getAdminEmails(function (error, adminEmails) {
|
||||
if (error) return console.log('Error getting admins', error);
|
||||
|
||||
var mailOptions = {
|
||||
from: mailConfig().from,
|
||||
to: config.provider() === 'caas' ? 'support@cloudron.io' : adminEmails.concat('support@cloudron.io').join(', '),
|
||||
subject: util.format('[%s] Failed to backup', config.fqdn()),
|
||||
text: render('backup_failed.ejs', { fqdn: config.fqdn(), message: message, format: 'text' })
|
||||
};
|
||||
|
||||
enqueue(mailOptions);
|
||||
});
|
||||
}
|
||||
|
||||
function certificateRenewalError(domain, message) {
|
||||
assert.strictEqual(typeof domain, 'string');
|
||||
assert.strictEqual(typeof message, 'string');
|
||||
|
||||
Reference in New Issue
Block a user