Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hugojosefson/duplicati-generate-config
Generate duplicati backup configs from a flat file.
https://github.com/hugojosefson/duplicati-generate-config
Last synced: 29 days ago
JSON representation
Generate duplicati backup configs from a flat file.
- Host: GitHub
- URL: https://github.com/hugojosefson/duplicati-generate-config
- Owner: hugojosefson
- Created: 2017-09-29T21:32:32.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:56:43.000Z (almost 2 years ago)
- Last Synced: 2024-11-22T14:09:37.763Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 942 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @hugojosefson/duplicati-generate-config
_Generate [duplicati](https://www.duplicati.com/) backup configs from a flat file._
[![Build Status](https://travis-ci.org/hugojosefson/duplicati-generate-config.svg?branch=master)](https://travis-ci.org/hugojosefson/duplicati-generate-config)
[![Coverage Status](https://coveralls.io/repos/github/hugojosefson/duplicati-generate-config/badge.svg?branch=master)](https://coveralls.io/github/hugojosefson/duplicati-generate-config?branch=master)
[![npm page](https://img.shields.io/npm/v/@hugojosefson/duplicati-generate-config.svg)](https://npmjs.com/package/@hugojosefson/duplicati-generate-config)
[![License MIT](https://img.shields.io/npm/l/@hugojosefson/duplicati-generate-config.svg)](https://tldrlegal.com/license/mit-license)
[![SemVer 2.0.0](https://img.shields.io/badge/SemVer-2.0.0-lightgrey.svg)](http://semver.org/spec/v2.0.0.html)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)Currently hard-coded for:
- `TargetURL` expected to be for B2 Cloud Storage by Backblaze (`b2://...`).
- Filter expressions based on using
[linuxserver/duplicati](https://hub.docker.com/r/linuxserver/duplicati/) in Docker.## Prerequisite
Node.js, at least `v13.2.0`.
Recommended to install latest via [nvm](https://github.com/creationix/nvm#readme):
```bash
nvm install stable
```## Usage
Just have the requisite Node.js installed, then:
```bash
npx @hugojosefson/duplicati-generate-config \
template-duplicati-config.json \
definitions.txt
```Will read from `definitions.txt`, outputting config files to current directory, using
`template-duplicati-config.json` as template.See also:
```bash
# 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 --help
```### Template 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/KeepVideos/programming to b2 backblaze
/home/me/Videos/ProgrammingImportant Downloads to b2 backblaze
/home/me/Important Downloadscode/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](#generatewritespecs)
- [Parameters](#parameters)
- [readFile](#readfile)
- [Parameters](#parameters-1)
- [writeFile](#writefile)
- [Parameters](#parameters-2)#### generateWriteSpecs
Converts duplicati template file contents, and backup definition flat file contents, into
definitions of what to write to disk.##### Parameters
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `options.template` **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** Promise of the contents of the duplicati template config file.
- `options.definitions` **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** Promise of the contents of the backup definitions flat file.
- `options.outputDir` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Where to say in the returned writeDefinition to write the files. (optional, default `"."`)
- `options.namePrefix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Prepended to each backup set name the definitions, to the resulting config file. (optional, default `""`)
- `options.nameSuffix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Appended to each backup set name the definitions, to the resulting config file. (optional, default `" to b2 backblaze"`)
- `options.sourcePathPrefix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Prepended to each source path in the definitions, to the resulting config file. (optional, default `"/source"`)
- `options.outputFilenamePrefix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Prepended to each written config filename. (optional, default `""`)
- `options.outputFilenameSuffix` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Appended to each written config filename. (optional, default `"-duplicati-config.json"`)Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<\[{filename, contents}]>** A Promise definitions of what to write to disk
#### readFile
Reads a file.
##### Parameters
- `filename` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Filename to read from.
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** A Promise of the contents of the file.
#### writeFile
Writes to a file.
##### Parameters
- `filename` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Filename to write to.
- `contents` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to write.Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** A Promise of the filename written.
### Example API usage
Implementation of the `generate` CLI command, shows how the above API is used:
[src/cli-commands/generate.mjs](src/cli-commands/generate.mjs#L56)