npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hugojosefson/duplicati-generate-config

v3.0.1

Published

Generate duplicati backup configs from a flat file

Downloads

2

Readme

@hugojosefson/duplicati-generate-config

Generate duplicati backup configs from a flat file.

Build Status Coverage Status npm page License MIT SemVer 2.0.0 JavaScript Style Guide

Currently hard-coded for:

  • TargetURL expected 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 stable

Usage

Just have the requisite Node.js installed, then:

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:

# 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/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
  • options Object
    • options.template Promise<String> Promise of the contents of the duplicati template config file.
    • options.definitions Promise<String> Promise of the contents of the backup definitions flat file.
    • options.outputDir String Where to say in the returned writeDefinition to write the files. (optional, default ".")
    • options.namePrefix String Prepended to each backup set name the definitions, to the resulting config file. (optional, default "")
    • options.nameSuffix String Appended to each backup set name the definitions, to the resulting config file. (optional, default " to b2 backblaze")
    • options.sourcePathPrefix String Prepended to each source path in the definitions, to the resulting config file. (optional, default "/source")
    • options.outputFilenamePrefix String Prepended to each written config filename. (optional, default "")
    • options.outputFilenameSuffix String 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
  • filename string Filename to read from.

Returns Promise<String> A Promise of the contents of the file.

writeFile

Writes to a file.

Parameters
  • filename string Filename to write to.
  • contents string String to write.

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:

src/cli-commands/generate.mjs