diff --git a/core/server/api/canary/db.js b/core/server/api/canary/db.js index 7f7323a914..a6113ec24c 100644 --- a/core/server/api/canary/db.js +++ b/core/server/api/canary/db.js @@ -1,5 +1,5 @@ const Promise = require('bluebird'); -const backupDatabase = require('../../data/db/backup'); +const dbBackup = require('../../data/db/backup'); const exporter = require('../../data/exporter'); const importer = require('../../data/importer'); const common = require('../../lib/common'); @@ -25,7 +25,7 @@ module.exports = { // NOTE: we need to have `include` property available as backupDatabase uses it internally Object.assign(frame.options, {include: frame.options.withRelated}); - return backupDatabase(frame.options); + return dbBackup.backup(frame.options); } }, @@ -114,7 +114,7 @@ module.exports = { }); } - return backupDatabase().then(deleteContent); + return dbBackup.backup().then(deleteContent); } } }; diff --git a/core/server/api/canary/users.js b/core/server/api/canary/users.js index f9cb703c3e..ecbe6d7620 100644 --- a/core/server/api/canary/users.js +++ b/core/server/api/canary/users.js @@ -1,6 +1,6 @@ const Promise = require('bluebird'); const common = require('../../lib/common'); -const backupDatabase = require('../../data/db/backup'); +const dbBackup = require('../../data/db/backup'); const models = require('../../models'); const permissionsService = require('../../services/permissions'); const ALLOWED_INCLUDES = ['count.posts', 'permissions', 'roles', 'roles.permissions']; @@ -122,7 +122,7 @@ module.exports = { }, permissions: true, async query(frame) { - const filename = await backupDatabase(); + const filename = await dbBackup.backup(); return models.Base.transaction((t) => { frame.options.transacting = t; diff --git a/core/server/api/v2/db.js b/core/server/api/v2/db.js index 7f7323a914..a6113ec24c 100644 --- a/core/server/api/v2/db.js +++ b/core/server/api/v2/db.js @@ -1,5 +1,5 @@ const Promise = require('bluebird'); -const backupDatabase = require('../../data/db/backup'); +const dbBackup = require('../../data/db/backup'); const exporter = require('../../data/exporter'); const importer = require('../../data/importer'); const common = require('../../lib/common'); @@ -25,7 +25,7 @@ module.exports = { // NOTE: we need to have `include` property available as backupDatabase uses it internally Object.assign(frame.options, {include: frame.options.withRelated}); - return backupDatabase(frame.options); + return dbBackup.backup(frame.options); } }, @@ -114,7 +114,7 @@ module.exports = { }); } - return backupDatabase().then(deleteContent); + return dbBackup.backup().then(deleteContent); } } }; diff --git a/core/server/data/db/backup.js b/core/server/data/db/backup.js index 91eb5ff0c6..ce18eed31a 100644 --- a/core/server/data/db/backup.js +++ b/core/server/data/db/backup.js @@ -39,4 +39,6 @@ backup = function backup(options) { }); }; -module.exports = backup; +module.exports = { + backup +}; diff --git a/core/test/unit/data/db/backup_spec.js b/core/test/unit/data/db/backup_spec.js index a926b48c29..2c2fee7a51 100644 --- a/core/test/unit/data/db/backup_spec.js +++ b/core/test/unit/data/db/backup_spec.js @@ -1,11 +1,10 @@ var should = require('should'), sinon = require('sinon'), - rewire = require('rewire'), _ = require('lodash'), fs = require('fs-extra'), models = require('../../../../server/models'), exporter = require('../../../../server/data/exporter'), - backupDatabase = rewire('../../../../server/data/db/backup'); + backupDatabase = require('../../../../server/data/db/backup'); describe('Backup', function () { var exportStub, filenameStub, fsStub; @@ -25,7 +24,7 @@ describe('Backup', function () { }); it('should create a backup JSON file', function (done) { - backupDatabase().then(function () { + backupDatabase.backup().then(function () { exportStub.calledOnce.should.be.true(); filenameStub.calledOnce.should.be.true(); fsStub.calledOnce.should.be.true();