mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -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
|
||||
// Provides for backing up the database before making potentially destructive changes
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs'),
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
Promise = require('bluebird'),
|
||||
config = require('../../config'),
|
||||
exporter = require('../export'),
|
||||
logging = require('../../logging'),
|
||||
utils = require('../../utils'),
|
||||
exporter = require('../export'),
|
||||
|
||||
writeExportFile,
|
||||
backup;
|
||||
|
@ -20,15 +20,10 @@ writeExportFile = function writeExportFile(exportResult) {
|
|||
/**
|
||||
* ## Backup
|
||||
* does an export, and stores this in a local file
|
||||
*
|
||||
* @param {{info: logger.info, warn: logger.warn}} [logger]
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
backup = function backup(logger) {
|
||||
// If we get passed a function, use it to output notices, else don't do anything
|
||||
logger = logger && _.isFunction(logger.info) ? logger : {info: _.noop};
|
||||
|
||||
logger.info('Creating database backup');
|
||||
backup = function backup() {
|
||||
logging.info('Creating database backup');
|
||||
|
||||
var props = {
|
||||
data: exporter.doExport(),
|
||||
|
@ -38,7 +33,7 @@ backup = function backup(logger) {
|
|||
return Promise.props(props)
|
||||
.then(writeExportFile)
|
||||
.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');
|
||||
|
||||
module.exports = function before(options) {
|
||||
|
|
|
@ -73,20 +73,5 @@ describe('Migrations', function () {
|
|||
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…
Reference in a new issue