A fast and portable CouchDB command line utility. See help below for more information. Built with Go.
Specifically this was built for maintaing a backup database by providing the following functionality:
Easily replicate an entire remote machine (except databases that begin with '_'). This can be run repeatedly, as it will skip over any existing replicators on the target.
couchdb-utils rep host maindb.example.com:5984 --continuous
Refresh/regenerate all views in the backup database to allow quick failover. This could be run from a cronjob or as an external process. See the couchdb faq for more info.
Speed is an important feature. Here's a general idea of what you can expect.
$ time couchdb-utils databases | wc -l 26 real 0m0.020s user 0m0.000s sys 0m0.000s $ time couchdb-utils views | wc -l 575 real 0m0.076s user 0m0.012s sys 0m0.016s
Run using local database on a linux virtual machine, YMMV.
There are no dependencies besides the included binary.
# refresh views in `mydb` database on host couch.example.com:1234, print views refreshed couchdb-utils refreshviews mydb --host=user:email@example.com:1234 -v # refresh all views on host couch.example.com:1234, print http requests couchdb-utils refreshviews --host=user:firstname.lastname@example.org:1234 -d # start continuous replication of all databases that do not begin with '_' # from `220.127.116.11:5984` to `user:email@example.com:5984` couchdb-utils rep host 18.104.22.168:5984 -h user:firstname.lastname@example.org:5984 -v
Usage: couchdb-utils [flags] couchdb-utils [command] Available Commands: version :: Prints the version number of couchdb-utils server :: Print basic server info stats [(<part1> <part2>)] :: Print server stats (optionally only a certain section eg: couchdb request_time). activetasks [<type>] :: Print active tasks (optionally filtering by type) session :: Print information about authenticated user databases :: Print all databases views [<db>...] :: Print all views (optionally filtering by database(s)) refreshviews [<db>...] [--verbose] :: Refresh views (optionally filtering by database(s)) rep <command>... :: Replication subcommands help [command] :: Help about any command Available Flags: -d, --debug=false: print http requests -h, --host="http://localhost:5984": Couchdb server url (http://user:password@host:port) -v, --verbose=false: chatty output
Usage: couchdb-utils rep <command>... [flags] couchdb-utils rep [command] Available Commands: list :: Print all replicators start <source> <target> [--create --continuous] :: Configure replication from source to target stop (<id>... | --all) [--verbose] :: Stop replicating given id(s) or all host <remote_host> [--create --continuous --verbose] :: Replicates all databases in remote host that do not begin with '_' Available Flags: -d, --debug=false: print http requests -h, --host="http://localhost:5984": Couchdb server url (http://user:password@host:port) -v, --verbose=false: chatty output
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request