I'm new in CouchDb, And sometimes I need to export my Database.
Until Now I used this command
curl -X GET http://127.0.0.1:5984/nomeDB/_all_docs\?include_docs\=true > /Users/bob/Desktop/db.json
But in this way, before import my Dump with this command
curl -d #db.json -H "Content-type: application/json" -X POST http://127.0.0.1:5984/dbName/_bulk_docs
I have to correct the Json with
"rows": [ =====> "docs": [
And in this way My documents have one more key, the doc key.
What is the best way to do a Dump to pass, for example, to another developer?
The easiest export/import and backup/restore strategy is to simply copy the raw database file. Usually, this file is located at /var/lib/couchdb/my-database.couch. You can safely copy this file, even while the database is running. (Source)
Another option is to use replication to copy entire databases between servers. This option can be done incrementally, unlike the first.
Related
Does anyone know where to get an offline version of the Asciidoctor's user manual: https://asciidoctor.org/docs/user-manual/
It is weird, how developers brag about Asciidoctor being able to export to PDF, HTML... But at the same time they fail to present a nice PDF document for offline use...
You can get the raw adoc source from: https://github.com/asciidoctor/asciidoctor.org/blob/master/docs/user-manual.adoc and convert it using asciidoctor.
Feel free to grab the result directly from:
https://sqli.dev/asciidoctor/user-manual.pdf (asciidoctor-pdf threw a few errors with this document, which I haven’t investigated, so some things may not show up as intended)
https://sqli.dev/asciidoctor/user-manual.html (this html will still fetch online resources for fonts, mathjax, etc.)
You can use the following to limit the amount of online resources needed:
git clone https://github.com/asciidoctor/asciidoctor.org.git
cd asciidoctor.org/docs
curl -O https://fontawesome.com/v4.7.0/assets/font-awesome-4.7.0.zip
7z x font-awesome-4.7.0.zip
asciidoctor -a !iconfont-remote=# -a icons=font -a stylesdir=font-awesome-4.7.0/css -a !webfonts=# user-manual.adoc
The resulting user-manual.html will only try to fetch the MathJax.js from a remote site.
I would recommend to open an issue at https://github.com/asciidoctor/asciidoctor.org proposing that they offer offline download options.
I am trying to figure out the best solution for below.
[user]:~>BLAH=$"cat text.txt"
[user]:~>ipa-getcert stop-tracking -i $BLAH
the text.txt document hosts the Request ID of a cert.
However, its not actually putting the info in the command. Is there an IPA command that can find and replace the old certs with out manual Request ID entries?
Or is there another way to inject the ID that is inside the text.txt?
I want import a csv data file straight into a table i've created in Azure. I understand that Bulk Insert isn't supported in Azure.
Please can anyone suggest a method for importing a flat file straight into Azure - I want to be able to do this straight from the command line (so that I can monitor the execution time using set statistics io on; ), and without syncing through SSIS or other applications. I've searched for guidance on this but all the articles I find appear to reference using BCP, but this appears to be an add-in?
Grateful for any suggestions.
R,
Jon
I've actually used the method stated here: Bulk insert with Azure SQL.
Basically you bulk insert your data to a local MSSQL database (which is supported).
Create a txt file with all data and bulk insert it into your azure table by using the BCP command in command prompt.
I ended up doing the same as Jefferey, but in case the site goes down here's the syntax:
BCP <databasename>.dbo.<tablename> IN <localfolder>\<filename>.txt -S <servername> -d <database> -U <username>#<servername> -P <password> -q -c -C -t ;
The -C enables you to use UTF-8 as needed for cases with special chars (like æøå).
I know that when you create a Document on Database A, replicate the Database, then make changes to it on DB A and DB B and THEN replicate again, you’ll get a conflict but both Versions exist in the Revision Tree.
But when you create a Doc with an Id XY on DB A and then create a Doc with the same Id but different content on DB B and then replicate, only one of the Version exists. The other one gets overwritten.
Is the reason for that, that because both documents have no version they descend from and so the Replication Algorithm can’t know that they both exist?
And if yes is there a way of saving both Versions?
Use Case is that there are two databases, one local, one online. they biderectionally sync. On both DBs User create docs. But I need to make sure IF the connection fails for a while that both CAN still create docs and I can merge them whenever the connection is back. I guess the hard Part here is the CREATE instead of UPDATE right?
Firstly, and for total clarity, CouchDB does not overwrite data. The only way for data you've written to be forgotten is to make a successful update to a document.
CouchDB will introduce new branches (aka conflicts) during replication to preserve all divergences of content. If what you've seen is reproducible then it's a bug. Below is my transcript though which shows that CouchDB indeed preserves both revisions as expected;
curl 127.0.0.1:5984/db1 -XPUT
{"ok":true}
curl 127.0.0.1:5984/db2 -XPUT
{"ok":true}
curl 127.0.0.1:5984/db1/mydoc -XPUT -d '{"foo":true}'
{"ok":true,"id":"mydoc","rev":"1-89248382088d08ccb7183515daf390b8"}
curl 127.0.0.1:5984/db2/mydoc -XPUT -d '{"foo":false}'
{"ok":true,"id":"mydoc","rev":"1-1153b140e4c8674e2e6425c94de860a0"}
curl 127.0.0.1:5984/_replicate -Hcontent-type:application/json -d '{"source":"db1","target":"db2"}'
{"ok":true,...}
curl '127.0.0.1:5984/db2/mydoc?conflicts=true'
{"_id":"mydoc","_rev":"1-89248382088d08ccb7183515daf390b8","foo":true,"_conflicts":["1-1153b140e4c8674e2e6425c94de860a0"]}
I have a couchdb installation which generally opens fine at futon, in "All documents" view i can see all the objects; however when i try accessing one of my views, i get this error after a couple of seconds "Error: file_corruption file corruption" in an alert dialog box.
The db has been moved between discs in past, as we changed the disks to make sure that we have enough space.
if the file is corrupt, it shouldn't work at all, is there any way i could repair the same.
The db is quite big already more than 150 GB; I even tried making the same view with diff name but the error persisted.
I think that moving files is a bad idea. You should better replicate your DB from old server to the new one.
$ curl -H 'Content-Type: application/json' -X POST http://newserver:5984/_replicate -d ' {"source": "http://oldserver:5984/foo", "target": "bar", "create_target": true} '
remove the couchdb index files and try again
they are located at either
/var/lib/couchdb/.{dbname}_design/
/usr/local/var/lib/couchdb/.{dbname}_design/