@hugojosefson/duplicati-generate-config v3.0.1
@hugojosefson/duplicati-generate-config
Generate duplicati backup configs from a flat file.
Currently hard-coded for:
TargetURLexpected to be for B2 Cloud Storage by Backblaze (b2://...).- Filter expressions based on using linuxserver/duplicati in Docker.
Prerequisite
Node.js, at least v13.2.0.
Recommended to install latest via nvm:
nvm install stableUsage
Just have the requisite Node.js installed, then:
npx @hugojosefson/duplicati-generate-config \
template-duplicati-config.json \
definitions.txtWill read from definitions.txt, outputting config files to current directory, using
template-duplicati-config.json as template.
See also:
# show available commands, currently only 'generate'
npx @hugojosefson/duplicati-generate-config --help
# show available options for the 'generate' command
npx @hugojosefson/duplicati-generate-config generate --helpTemplate file format
Export an existing configuration from duplicati, and use that file.
Definitions file format
Example definitions.txt:
# 1st line of every block is name of backup set.
# 2nd line is source directory.
# Following lines are exclusions.
# Empty line denotes end of block, and that backup set.
virtual-machines/Keep to b2 backblaze
/home/me/virtual-machines/Keep
Videos/programming to b2 backblaze
/home/me/Videos/Programming
Important Downloads to b2 backblaze
/home/me/Important Downloads
code/old-stuff to b2 backblaze
/home/me/code/old-stuff
*/node_modules/
*/target/
code to b2 backblaze
/home/me/code
/home/me/code/old-stuff/
*/node_modules/
*/target/
/home/me to b2 backblaze
/home/me
/home/me/code/
/home/me/virtual-machines/
/home/me/Important Downloads/
/home/me/Downloads/
/home/me/duplicati/backups/
/home/me/lost+found/
/home/me/Videos/
/home/me/.Trash-1000/
*/node_modules/
*/target/Programmatic access
You can also import the module, and use its exported functions programmatically.
API
Table of Contents
generateWriteSpecs
Converts duplicati template file contents, and backup definition flat file contents, into definitions of what to write to disk.
Parameters
optionsObjectoptions.templatePromise<String> Promise of the contents of the duplicati template config file.options.definitionsPromise<String> Promise of the contents of the backup definitions flat file.options.outputDirString Where to say in the returned writeDefinition to write the files. (optional, default".")options.namePrefixString Prepended to each backup set name the definitions, to the resulting config file. (optional, default"")options.nameSuffixString Appended to each backup set name the definitions, to the resulting config file. (optional, default" to b2 backblaze")options.sourcePathPrefixString Prepended to each source path in the definitions, to the resulting config file. (optional, default"/source")options.outputFilenamePrefixString Prepended to each written config filename. (optional, default"")options.outputFilenameSuffixString Appended to each written config filename. (optional, default"-duplicati-config.json")
Returns Promise<[{filename, contents}]> A Promise definitions of what to write to disk
readFile
Reads a file.
Parameters
filenamestring Filename to read from.
Returns Promise<String> A Promise of the contents of the file.
writeFile
Writes to a file.
Parameters
Returns Promise<String> A Promise of the filename written.
Example API usage
Implementation of the generate CLI command, shows how the above API is used: