-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackupConfig.js
43 lines (35 loc) · 1 KB
/
backupConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const stat = require('fs').statSync;
const path = require('path');
const AdmZip = require('adm-zip');
/**
* Backup Konfiguration
*/
newArchive(`C:/Temp/soa-dashboard-config-backup-${+new Date}.zip`, [
'./customisation',
'./frontend/src/customisation',
'./frontend/.env',
]);
/**
* @param {String} zipFileName
* @param {Array<String>} pathNames
*/
function newArchive(zipFileName, pathNames) {
const zip = new AdmZip();
pathNames.forEach(pathName => {
const absoluteName = path.join(__dirname, pathName)
const p = stat(absoluteName);
if (p.isFile()) {
console.log('Add File', absoluteName)
zip.addLocalFile(absoluteName, pathName);
} else if (p.isDirectory()) {
console.log('Add Directory', absoluteName)
zip.addLocalFolder(absoluteName, pathName);
}
});
zip.writeZip(zipFileName);
console.log(`
BACKUP der Konfiguration
Verzeichnisse ${pathNames.join(', ')} nach ${zipFileName} gesichert.
Extrahiere mit 7-Zip, Windows zeigt keine Dateien an.
`)
}