mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 fix backup database (#7898)
refs #7489 The require path for the db backup was wrong. The before hook could not execute db backup. Furthermore, i have replaced the logging in the backup script.
This commit is contained in:
parent
ee3033cde5
commit
0424c6675c
3 changed files with 7 additions and 27 deletions
|
@ -1,12 +1,12 @@
|
||||||
// # Backup Database
|
// # Backup Database
|
||||||
// Provides for backing up the database before making potentially destructive changes
|
// Provides for backing up the database before making potentially destructive changes
|
||||||
var _ = require('lodash'),
|
var fs = require('fs'),
|
||||||
fs = require('fs'),
|
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
Promise = require('bluebird'),
|
Promise = require('bluebird'),
|
||||||
config = require('../../config'),
|
config = require('../../config'),
|
||||||
exporter = require('../export'),
|
logging = require('../../logging'),
|
||||||
utils = require('../../utils'),
|
utils = require('../../utils'),
|
||||||
|
exporter = require('../export'),
|
||||||
|
|
||||||
writeExportFile,
|
writeExportFile,
|
||||||
backup;
|
backup;
|
||||||
|
@ -20,15 +20,10 @@ writeExportFile = function writeExportFile(exportResult) {
|
||||||
/**
|
/**
|
||||||
* ## Backup
|
* ## Backup
|
||||||
* does an export, and stores this in a local file
|
* does an export, and stores this in a local file
|
||||||
*
|
|
||||||
* @param {{info: logger.info, warn: logger.warn}} [logger]
|
|
||||||
* @returns {Promise<*>}
|
* @returns {Promise<*>}
|
||||||
*/
|
*/
|
||||||
backup = function backup(logger) {
|
backup = function backup() {
|
||||||
// If we get passed a function, use it to output notices, else don't do anything
|
logging.info('Creating database backup');
|
||||||
logger = logger && _.isFunction(logger.info) ? logger : {info: _.noop};
|
|
||||||
|
|
||||||
logger.info('Creating database backup');
|
|
||||||
|
|
||||||
var props = {
|
var props = {
|
||||||
data: exporter.doExport(),
|
data: exporter.doExport(),
|
||||||
|
@ -38,7 +33,7 @@ backup = function backup(logger) {
|
||||||
return Promise.props(props)
|
return Promise.props(props)
|
||||||
.then(writeExportFile)
|
.then(writeExportFile)
|
||||||
.then(function successMessage(filename) {
|
.then(function successMessage(filename) {
|
||||||
logger.info('Database backup written to: ' + filename);
|
logging.info('Database backup written to: ' + filename);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var backup = require('../../../schema/backup'),
|
var backup = require('../../../db/backup'),
|
||||||
models = require('../../../../models');
|
models = require('../../../../models');
|
||||||
|
|
||||||
module.exports = function before(options) {
|
module.exports = function before(options) {
|
||||||
|
|
|
@ -73,20 +73,5 @@ describe('Migrations', function () {
|
||||||
done();
|
done();
|
||||||
}).catch(done);
|
}).catch(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fall back to console.log if no logger provided', function (done) {
|
|
||||||
var noopStub = sandbox.stub(_, 'noop');
|
|
||||||
|
|
||||||
backupDatabase().then(function () {
|
|
||||||
exportStub.calledOnce.should.be.true();
|
|
||||||
filenameStub.calledOnce.should.be.true();
|
|
||||||
fsStub.calledOnce.should.be.true();
|
|
||||||
noopStub.calledTwice.should.be.true();
|
|
||||||
// restore early so we get the test output
|
|
||||||
noopStub.restore();
|
|
||||||
|
|
||||||
done();
|
|
||||||
}).catch(done);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue