Improved simple server backup.
This commit is contained in:
parent
40eac9b188
commit
a934d723b9
|
@ -1603,11 +1603,16 @@ function CreateMeshCentralServer(config, args) {
|
|||
// An entry's fileName implicitly requires its parent directories to exist.
|
||||
zipfile.readEntry();
|
||||
} else {
|
||||
// file entry
|
||||
// File entry
|
||||
zipfile.openReadStream(entry, function (err, readStream) {
|
||||
if (err) throw err;
|
||||
readStream.on('end', function () { zipfile.readEntry(); });
|
||||
// console.log('Extracting:', obj.getConfigFilePath(entry.fileName));
|
||||
var directory = obj.path.dirname(entry.fileName);
|
||||
if (directory != '.') {
|
||||
directory = obj.getConfigFilePath(directory)
|
||||
if (obj.fs.existsSync(directory) == false) { obj.fs.mkdirSync(directory); }
|
||||
}
|
||||
//console.log('Extracting:', obj.getConfigFilePath(entry.fileName));
|
||||
readStream.pipe(obj.fs.createWriteStream(obj.getConfigFilePath(entry.fileName)));
|
||||
});
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9221,7 +9221,7 @@
|
|||
var x = "Restore the server using a backup, <span style=color:red>this will delete the existing server data</span>. Only do this if you know what you are doing." + '<br /><br />';
|
||||
x += '<form action="/restoreserver.ashx" enctype="multipart/form-data" method="post"><div>';
|
||||
x += '<input type=hidden name=auth value=' + authCookie + '>';
|
||||
x += '<input id=account_dlgFileInput type=file name=datafile style=width:100% accept=".zip,application/octet-stream,application/zip,application/x-zip,application/x-zip-compressed" onchange=account_validateServerRestore()>';
|
||||
x += '<input id=account_dlgFileInput type=file name=datafile style=width:100% accept=".zip,application/octet-stream,application/zip,application/x-zip,application/x-zip-compressed" onchange=account_validateServerRestore()><br /><br />';
|
||||
x += '<input id=account_dlgCancelButton type=button value=' + "Cancel" + ' style=float:right;width:80px;margin-left:5px onclick=dialogclose(0)>';
|
||||
x += '<input id=account_dlgOkButton type=submit value=' + "OK" + ' style=float:right;width:80px onclick=dialogclose(1)>';
|
||||
x += '</div><br /><br /></form>';
|
||||
|
|
12
webserver.js
12
webserver.js
|
@ -4032,13 +4032,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||
// Pipe archive data to the file
|
||||
archive.pipe(res);
|
||||
|
||||
// Append all of the files for this backup
|
||||
var backupList = ['config.json', 'meshcentral.db', 'agentserver-cert-private.key', 'agentserver-cert-public.crt', 'mpsserver-cert-private.key', 'mpsserver-cert-public.crt', 'data/root-cert-private.key', 'root-cert-public.crt', 'webserver-cert-private.key', 'webserver-cert-public.crt'];
|
||||
for (var i in backupList) {
|
||||
var filename = backupList[i];
|
||||
var filepath = obj.path.join(obj.parent.datapath, filename);
|
||||
if (obj.fs.existsSync(filepath)) { archive.file(filepath, { name: filename }); }
|
||||
}
|
||||
// Append files from a glob pattern
|
||||
archive.directory(obj.parent.datapath, false);
|
||||
|
||||
// Finalize the archive (ie we are done appending files but streams have to finish yet)
|
||||
archive.finalize();
|
||||
|
@ -4067,7 +4062,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||
const user = obj.users[req.session.userid];
|
||||
if ((user == null) || ((user.siteadmin & 4) == 0)) { res.sendStatus(401); return; } // Check if we have server restore rights
|
||||
|
||||
res.send('Server must be restarted, <a href="' + domain.url + '">click here to login</a>.');
|
||||
res.set('Content-Type', 'text/html');
|
||||
res.end('<html><body>Server must be restarted, <a href="' + domain.url + '">click here to login</a>.</body></html>');
|
||||
parent.Stop(files.datafile[0].path);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue