danielebailo / couchdb-dump

Bash command line scripts to dump &restore a couchdb database
Other
367 stars 129 forks source link

Backup all databases #85

Open skycult opened 4 years ago

skycult commented 4 years ago

Hello, there is an option to backup/restore all databases? Thank you!

PulkitSolulab commented 4 years ago

Hello, there is an option to backup/restore all databases? Thank you!

Did you find anything till now. How to take all Databases at once

skycult commented 3 years ago

I created a nodejs small cli app to get a full databases list calling the script for every list item.

greenais commented 3 years ago

@skycult could you please share your app? I have plenty of DBs to backup so not inventing wheel once again would be quite time-saving)

dalgibbard commented 3 years ago

Just curl couchdb, parse it with jq, and pass the list into a for loop? :)

abheyogy commented 3 years ago

Its a simple curl, please find the snippet in BASH below:

for i in $(curl -X GET http://127.0.0.1:5984/_all_dbs); do \
         i=${i//[/}; i=${i//]/}; i=${i//\"/}
         IFS=, read -ra dbname <<< "$i"
done

for db in "${dbname[@]}"; do \
    echo $db;
done
schwichti commented 3 years ago

Shouldn't that line be

for db in "${dbname[@]}"; do \
abheyogy commented 3 years ago

Shouldn't that line be

for db in "${dbname[@]}"; do \

Yes, it was a typo, updated. Thanks for pointing it out.

schwichti commented 3 years ago

Thanks for sharing the snippet

backspace commented 1 year ago

Also thanks, I adapted it to extract all the databases into a directory:

for i in $(curl -X GET http://127.0.0.1:5984/_all_dbs); do \
         i=${i//[/}; i=${i//]/}; i=${i//\"/}
         IFS=, read -ra dbname <<< "$i"
done

for db in "${dbname[@]}"; do \
    echo $db;
    ./couchdb-dump.sh -b -H 127.0.0.1 -d ${db} -f dbs/${db}.json
done