Skip to content

Bash command line scripts to dump &restore a couchdb database

Notifications You must be signed in to change notification settings

camechis/couchdb-dump

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 

Repository files navigation

Couchdb-dump (& restore)

It works on LINUX/UNIX, Bash based systems (MacOSx)

Bash command line script(s) to EASILY dump&restore a couchdb database

  • Needs bash
  • Dumped database is outputted into stdout (screen)

##Quickstart (& quickend) Dump: bash couchdb-dump.sh mycouch.com my-db > dumped-db.txt

Restore: bash couchdb-restore.sh mycouch.com my-db dumped-db.txt

##Quickstart (& quickend) with user & pass Dump: bash couchdb-dump.sh user:pass@mycouch.com my-db > dumped-db.txt

Restore: bash couchdb-restore.sh user:pass@mycouch.com my-db dumped-db.txt

Why do you need it?

Surprisingly there is not a straightforward way to dump a couchdb database. Often you are suggested to replicate it or to dump it with the couchdb _all_docs directive.

But using _all_docs directive you have as output a JSON object which cannot be used to directly re-upload the database to couchdb.

Hence, the goal of this script(s) is to give you a simple way to download & upload your couchdb database.

DUMP Usage

When launched it takes as arguments:

  • url of database (without http://)
  • database name

Just write in the command line:

bash couchdb-dump DB_URL... DB_NAME...

DB_URL: the url of the couchdb instance without 'http://', e.g. mycouch.com

DB_NAME: name of the database, e.g. 'my-db'

Example

bash couchdb-dump.sh mycouch.com my-db

Saving output to file

bash couchdb-dump.sh mycouch.com my-db > dumped-db.txt

RESTORE usage

When launched it takes as arguments:

  • url of database (without http://) NB: if log-in is enabled the url is like user:pass@my-url.com
  • database name
  • file containing dumped database

Just write in the command line:

bash couchdb-restore.sh URL... DB_NAME... DUMPED_DB_FILENAME...

DB_URL: the url of the couchdb instance without 'http://', e.g. mycouch.com

DB_NAME: name of the database, e.g. 'my-db'

DUMPED_DB_FILENAME... : file containing the JSON object with all the docs

Example

bash couchdb-restore.sh user:pass@mycouch.com my-db dumpedDB.txt

TODO

Add -p option to use an arbitrary port (5984 is the default one)

About

Bash command line scripts to dump &restore a couchdb database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%