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

@neoskop/bouch

v0.4.0

Published

CouchDB/PouchDB Backup/Restore Tool with Attachments Support

Downloads

29

Readme

@neoskop/bouch

Bouch is an CLI Tool to backup and restore CouchDB and PouchDB databases.
You can choose betwen JSON and BSON format and Gzip, Brotli or no compression

Install

$ yarn global add @neoskop/bouch
$ npm install -g @neoskop/bouch

Usage

Backup

$ bouch backup http://localhost:5984/dbname
$ bouch backup --help
bouch backup <url>

Backup a couchdb database

Positionals:
  url  Database URL                                                   [required]

Options:
  --help                Show help                                      [boolean]
  --version             Show version number                            [boolean]
  --format, -F          File format (ignored in migrate), default: bson
                                                       [choices: "bson", "json"]
  --compress, -C        File compression (ignored in migrate), default: none
                                                   [choices: "none", "gz", "br"]
  --quiet, -q           Supress any non error output  [boolean] [default: false]
  --multi-database, -m  Process multiple databases    [boolean] [default: false]
  --filter              Filter for db names (use with --multi-database)
  --rename, -r          Code to rename databases in multi-database mode
  --file, -f            File to create
  --stdout              Output to stdout instead of file
                                                      [boolean] [default: false]
  --chunk-size, -c      Number of documents read/write at once
                                                        [number] [default: 1000]

Restore

$ bouch restore backup-file.bson http://localhost:5984/dbname
$ bouch restore --help
bouch restore <file> <url>

Restore a backup

Positionals:
  file  Backup file                                                   [required]
  url   Database URL                                                  [required]

Options:
  --help                Show help                                      [boolean]
  --version             Show version number                            [boolean]
  --format, -F          File format (ignored in migrate), default: bson
                                                       [choices: "bson", "json"]
  --compress, -C        File compression (ignored in migrate), default: none
                                                   [choices: "none", "gz", "br"]
  --quiet, -q           Supress any non error output  [boolean] [default: false]
  --multi-database, -m  Process multiple databases    [boolean] [default: false]
  --filter              Filter for db names (use with --multi-database)
  --rename, -r          Code to rename databases in multi-database mode
  --chunk-size, -c      Number of documents read/write at once
                                                        [number] [default: 1000]

Migrate

$ bouch migrate http://localhost:5984/dbname http://localhost:5984/dbname-new
$ bouch migrate --help
bouch migrate <from> <to>

Copy from one database to another

Positionals:
  from  From Database                                                 [required]
  to    To Database                                                   [required]

Options:
  --help                Show help                                      [boolean]
  --version             Show version number                            [boolean]
  --format, -F          File format (ignored in migrate), default: bson
                                                       [choices: "bson", "json"]
  --compress, -C        File compression (ignored in migrate), default: none
                                                   [choices: "none", "gz", "br"]
  --quiet, -q           Supress any non error output  [boolean] [default: false]
  --multi-database, -m  Process multiple databases    [boolean] [default: false]
  --filter              Filter for db names (use with --multi-database)
  --rename, -r          Code to rename databases in multi-database mode
  --chunk-size, -c      Number of documents read/write at once
                                                         [number] [default: 100]

Multi Database

To backup a whole database provide the option --multi-database. For example: bouch backup http://localhost:5984

Filtering

To filter the processed databases use the --filter option, where you can provide a minimatch pattern. Only works for backup and migrate. For example: bouch backup http://localhost:5984 --multi-database --filter 'prefix-*'

Renaming

To rename the restored databases use the --rename option, where you can provide a JS code to manipulate the target database names. Only works for restore and migrate.

Examples:

$ bouch migrate http://localhost:5984 --multi-database --filter 'prefix-*' --rename 'name.replace(/^prefix-/, "prefix2-")'

or use a file to define the renaming script.

// content of renaming.js
const map = {
  foo: 'bar',
  baz: 'foobar'
}

const arr = name.split(/-/);

arr[0] = map[arr[0]];

return arr.join('-')
$ bouch migrate http://localhost:5984 --multi-database --filter '(foo|bar)-*' --rename @renaming.js

License

MIT License

Copyright (c) 2019 Neoskop GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sponsor

Neoskop GmbH