mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: restore env
This commit is contained in:
1 parent
4dd02b3b4b
commit
1c26f25654
2 files changed
+5
-2
No files matched your search
@@ -85,7 +85,7 @@ if (argv.args[0] === 'backup') {
|
||||
const dbConfig = fs.readFileSync(path.resolve(hydroPath, 'config.json'), 'utf-8');
|
||||
const url = buildUrl(JSON.parse(dbConfig));
|
||||
const dir = `${os.tmpdir()}/${Math.random().toString(36).substring(2)}`;
|
||||
child.spawnSync('mongodump', [url, `--out=${dir}`], { stdio: 'inherit' });
|
||||
child.spawnSync('mongodump', [url, `--out=${dir}/dump`], { stdio: 'inherit' });
|
||||
const env = `${os.homedir()}/.hydro/env`;
|
||||
if (fs.existsSync(env)) fs.copySync(env, `${dir}/env`);
|
||||
const target = `${process.cwd()}/backup-${new Date().toISOString()}.zip`;
|
||||
@@ -112,6 +112,9 @@ if (argv.args[0] === 'restore') {
|
||||
child.spawnSync('rm', ['-rf', '/data/file/**'], { stdio: 'inherit' });
|
||||
child.spawnSync('mv', ['-f', `${dir}/file/**`, '/data/file'], { stdio: 'inherit' });
|
||||
}
|
||||
if (fs.existsSync(`${dir}/env`)) {
|
||||
fs.copySync(`${dir}/env`, `${os.homedir()}/.hydro/env`, { overwrite: true });
|
||||
}
|
||||
fs.removeSync(dir);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "3.1.45",
|
||||
"version": "3.1.46",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
Reference in new issue
Block a user