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

@originalfunko/docker-lifevest

v1.0.0

Published

A utility to backup or transfer a Docker Swarm.

Downloads

3

Readme

A utility to backup or transfer a Docker Swarm.

Why should I use this?

Existing Swarm backup strategies require root filesystem access, are stored in encrypted proprietary formats, and if you've fallen prey to a Swarm-corrupting bug the backup will retain that bug like an infection.

Lifevest creates plain JSON backups that are reconstructed from scratch upon restore. This means that your services, configurations, and secrets can live outside of Docker's Raft configurations, are immune to Swarm corruption bugs, and can serve as a single source of truth for Docker upgrades or automated processes.

Usage

Install this utility by running:

npm install -g @OriginalFunko/docker-lifevest

A quick reference is available with docker-lifevest --help.

A few common usages are below:

Backup a Swarm

To take a backup of a Swarm, run:

docker-lifevest --source <docker swarm IP or DNS>

A folder called backup-<datetime> will be created in the current directory. The directory looks like this:

backup-<datetime>
├ services - <JSON dumps of services>
├ configs - <JSON dumps of configs>
└ secrets - <JSON dumps of secrets>

To change the output directory, add --destination <new folder path>

Secrets are not encrypted in this backup, so please treat the backup carefully.

It is recommended to encrypt them:

tar cvz - backup-20XX-01-01T00-00-00-000Z/ |\
openssl enc \
  -kfile myFileContainingAPassword.txt \
  -aes-256-cbc \
  -out backup-20XX-01-01T00-00-00-000Z.tar.gz.enc

To decrypt this backup later:

openssl enc \
  -d \
  -kfile myFileContainingAPassword.txt \
  -aes-256-cbc \
  -in backup-20XX-01-01T00-00-00-000Z.tar.gz.enc |\
tar xz

Restore from Backup

To restore from a backup folder, run:

docker-lifevest --input folder --source <folder path> --output swarm --destination <docker swarm IP or DNS>

If your services pull from a private registry, you must create a JSON file containing authentication for that registry at registry-credentials.json. See Registry Authentication.

Existing items will not be replaced; it is recommended that you restore to a clean Swarm by doing something like the following:

systemctl stop docker
rm -rf /var/lib/docker/swarm
systemctl start docker
docker swarm init

Copy from Swarm to Swarm

To copy from one Swarm to another without an intermediate backup, run docker-lifevest --source <source IP or DNS> --output swarm --destination <dest IP or DNS>

Registry Authentication

If your services use authentication when pulling their images, you will need to create a JSON file containing those credentials in order to restore those services.

The JSON file must follow Docker's API format. Only services with images matching the serveraddress field in that file will use the authentication credentials, so images from other registries will not be affected.

When using --output swarm, add this file with the --registry-credentials <file path> flag.

Flags

| Flag | Aliases | Default | Description | | ------------------------ | -------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------- | | --input | --in, -i | swarm | The type of source. Valid values are swarm, folder | | --source | -s | N/A | The source. If input is swarm, an IP or DNS name. If folder, a path to a previously created backup. | | --output | --out, -o | folder | The type of destination. Valid values are swarm, folder. | | --destination | --dest, -d | N/A | The destination. If output is swarm, an IP or DNS name. If folder, default is backup-<timestamp> | | --registry-credentials | -R | N/A | A path to a JSON file used to specify registry authentication. See Registry Authentication for details. | | --verbose | -v | | Add up to three times to increase logging. | | --quiet | -q | | Add to silence all logging. | | --help | -? | | Add to show a quick reference. | | --porcelain | | | Mainly used for test suite, will make the script output a JSON blob of source and destination paths. |

Known Issues / TODO

Currently only services, configs, and secrets are backed up. More object types may be added in the future.

TLS support for Docker access.

Per-service registry authentication

License

This software is licensed under the Mozilla Public License 2.0. The full text of the license is included with this software.