- Source:
The WSH (Windows Script Host) CLI that updates or mirrors directories according to the schema defined in a JSON file.
Requires
Methods
(static) archiveDir(srcDir, dest, optionsopt) → {typeDeflateResult|Array.<typeDeflateResult>|string|Array.<string>}
- Source:
Compresses the directory into archive file (ZIP or RAR).
Example
var dirBkup = Wsh.DirBackUpper; // Shorthand
var srcDir = 'C:\\Users';
var dest = 'D:\\BackUp\\Users\\#{yyyy}\\#{MM - 1}';
dirBkup.archiveDir(srcDir, dest, {
archiveType: 'ZIP',
ignoredRegExp": ["\\.git.*"],
archiveOptions": {
exe7z: exe7z
dateCode: 'yyyy-MM-dd_hhmmss',
compressLv: 9,
password: 'This is mY&p@ss ^_<',
},
logger: 'warn/winEvent' // See https://github.com/tuckn/WshLogger
});
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
srcDir |
string | The source directory path to back up. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
dest |
string | The destination directory path. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Optional parameters. Properties
|
Returns:
- @see typeDeflateResult. If options.isDryRun is true, returns string.
- Type
- typeDeflateResult | Array.<typeDeflateResult> | string | Array.<string>
(static) backupDir(srcDir, destDir, optionsopt) → {void}
- Source:
Backs up the directory.
Example
var dirBkup = Wsh.DirBackUpper; // Shorthand
var srcDir = 'C:\\Users';
var destDir = 'D:\\BackUp\\Users\\#{yyyy}\\#{MM - 1}';
dirBkup.backupDir(srcDir, destDir, {
sync: 'MIRROR',
comparison: 'CONTENT',
ignoredRegExp: 'tmp$',
logger: 'warn/winEvent' // See https://github.com/tuckn/WshLogger
});
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
srcDir |
string | The source directory path to back up. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
destDir |
string | The destination directory path. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
<optional> |
Optional parameters. Properties
|
Returns:
- Type
- void
(static) backupDirUsingSchema(schema, taskNameopt, optionsopt) → {void}
- Source:
Backs up the directories.
Example
var dirBkup = Wsh.DirBackUpper; // Shorthand
var schema = {
description: 'Example Schema WshDirBackUpper',
components: {
dest: '\\\\MyNas\\BackUp',
exe7z: 'D:\\My Apps\\7-Zip\\7z.exe',
anyVal1: null
},
tasks: {
userAppData: {
description: 'Example task with options',
srcDir: 'C:\\Users\\Default\\AppData',
destDir: '${dest}\\AppData\\#{yyyy}\\#{MM-dd}',
method: 'UPDATE',
options: {
comparison: 'TIME',
ignoredRegExp: [
'Windows\\\\WebCache',
'Packages\\\\.*Cache\\\\',
'\\.mui$',
'\\.settingcontent-ms$'
]
}
},
'userAppData:zip': {
srcDir: 'C:\\Users\\Default\\AppData',
destDir: '${dest}\\AppData\\archives',
method: 'ARCHIVE',
options: {
ignoredRegExp: ['\\.git.*'],
archiveType: 'ZIP',
archiveOptions: {
exe7z: '${exe7z}',
dateCode: 'yyyy-MM-dd',
compressLv: 9,
password: 'This is mY&p@ss ^_<'
},
additionalArchiveOptions: {
'Visual Studio Code': {
excludingFiles: [
'*\\data\\user-data\\*Cache*\\*',
'*\\data\\user-data\\logs\\*',
'*\\data\\user-data\\*\\*\\LOCK'
]
}
}
}
},
'appLog:current': {
srcDir: 'D:\\AppLogs\\#{yyyy}\\#{MM}',
destDir: '${dest}\\AppLogs\\#{yyyy}\\#{MM}',
method: 'MIRROR',
options: {
comparison: 'CONTENT',
matchedRegExp: '\\.csv$'
}
},
'appLog:lastMonth': {
available: false,
srcDir: '${anyVal1}:\\AppLogs\\#{yyyy\\[MM-1]}',
destDir: '${dest}\\AppLogs\\#{yyyy\\[MM-1]}',
method: 'MIRROR',
options: {
comparison: 'TIME',
matchedRegExp: '\\.csv$'
}
}
}
};
dirBkup.backupDirUsingSchema(schema, 'work:*', {
logger: 'info/console',
overwrites: { anyVal1: 'E' }
});
// Only process appLog:current. appLog:lastMonth is not processed because available is false.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
schema |
typeSchemaBackUpper | ||||||||||||||||||||||
taskName |
string |
<optional> |
The task name to back up. |
||||||||||||||||||||
options |
object |
<optional> |
Optional parameters. Properties
|
Returns:
- Type
- void