Add database.exportToFile
This commit is contained in:
@@ -526,13 +526,7 @@ function snapshotBox(callback) {
|
|||||||
|
|
||||||
log('Snapshotting box');
|
log('Snapshotting box');
|
||||||
|
|
||||||
var password = config.database().password ? '-p' + config.database().password : '--skip-password';
|
database.exportToFile(`${paths.BOX_DATA_DIR}/box.mysqldump`, function (error) {
|
||||||
var mysqlDumpArgs = [
|
|
||||||
'-c',
|
|
||||||
`/usr/bin/mysqldump -u root ${password} --single-transaction --routines \
|
|
||||||
--triggers ${config.database().name} > "${paths.BOX_DATA_DIR}/box.mysqldump"`
|
|
||||||
];
|
|
||||||
shell.exec('backupBox', '/bin/bash', mysqlDumpArgs, { }, function (error) {
|
|
||||||
if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error));
|
if (error) return callback(new BackupsError(BackupsError.INTERNAL_ERROR, error));
|
||||||
|
|
||||||
return callback();
|
return callback();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ exports = module.exports = {
|
|||||||
commit: commit,
|
commit: commit,
|
||||||
|
|
||||||
importFromFile: importFromFile,
|
importFromFile: importFromFile,
|
||||||
|
exportToFile: exportToFile,
|
||||||
|
|
||||||
_clear: clear
|
_clear: clear
|
||||||
};
|
};
|
||||||
@@ -199,3 +200,14 @@ function importFromFile(file, callback) {
|
|||||||
child_process.exec.bind(null, cmd)
|
child_process.exec.bind(null, cmd)
|
||||||
], callback);
|
], callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exportToFile(file, callback) {
|
||||||
|
assert.strictEqual(typeof file, 'string');
|
||||||
|
assert.strictEqual(typeof callback, 'function');
|
||||||
|
|
||||||
|
var password = config.database().password ? '-p' + config.database().password : '--skip-password';
|
||||||
|
var cmd = `/usr/bin/mysqldump -u root ${password} --single-transaction --routines \
|
||||||
|
--triggers ${config.database().name} > "${file}"`;
|
||||||
|
|
||||||
|
child_process.exec(cmd, callback);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user