Created
February 27, 2022 20:43
-
-
Save nickva/5a89198c62fdd3ec97693c87833d5738 to your computer and use it in GitHub Desktop.
Simple CouchDB replication setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -xe | |
| DB=http://adm:pass@localhost:15984 | |
| http $DB | |
| http -b delete $DB/_replicator | |
| http -b delete $DB/source | |
| http -b delete $DB/target | |
| http -b put $DB/_replicator | |
| http -b put $DB/source | |
| http -b put $DB/source/doc1 a=b | |
| http -b put $DB/target | |
| http -b put $DB/_replicator/repdoc source="$DB/source" target="$DB/target" continuous:='true' | |
| sleep 6 | |
| http -b $DB/_scheduler/docs | |
| http -b $DB/target/_all_docs | |
| ### example output (http is httpie client) | |
| # + DB=http://adm:pass@localhost:15984 | |
| # + http http://adm:pass@localhost:15984 | |
| # HTTP/1.1 200 OK | |
| # Server: CouchDB/3.2.1 (Erlang OTP/22) | |
| # { | |
| # "couchdb": "Welcome", | |
| # "features": [ | |
| # "access-ready", | |
| # "partitioned", | |
| # "pluggable-storage-engines", | |
| # "reshard", | |
| # "scheduler" | |
| # ], | |
| # "git_sha": "244d428", | |
| # "uuid": "fake_uuid_for_dev", | |
| # "vendor": { | |
| # "name": "The Apache Software Foundation" | |
| # }, | |
| # "version": "3.2.1" | |
| # } | |
| # + http -b delete http://adm:pass@localhost:15984/_replicator | |
| # { | |
| # "ok": true | |
| # } | |
| # + http -b delete http://adm:pass@localhost:15984/source | |
| # { | |
| # "ok": true | |
| # } | |
| # + http -b delete http://adm:pass@localhost:15984/target | |
| # { | |
| # "ok": true | |
| # } | |
| # + http -b put http://adm:pass@localhost:15984/_replicator | |
| # { | |
| # "ok": true | |
| # } | |
| # + http -b put http://adm:pass@localhost:15984/source | |
| # { | |
| # "ok": true | |
| # } | |
| # + http -b put http://adm:pass@localhost:15984/source/doc1 a=b | |
| # { | |
| # "id": "doc1", | |
| # "ok": true, | |
| # "rev": "1-4b8a35d3f70a5962f86c6dd06ceb599c" | |
| # } | |
| # + http -b put http://adm:pass@localhost:15984/target | |
| # { | |
| # "ok": true | |
| # } | |
| # + http -b put http://adm:pass@localhost:15984/_replicator/repdoc source=http://adm:pass@localhost:15984/source target=http://adm:pass@localhost:15984/target continuous:=true | |
| # { | |
| # "id": "repdoc", | |
| # "ok": true, | |
| # "rev": "1-84c3dadd54688a80ad5d65abf130f790" | |
| # } | |
| # + sleep 6 | |
| # + http -b http://adm:pass@localhost:15984/_scheduler/docs | |
| # { | |
| # "docs": [ | |
| # { | |
| # "database": "_replicator", | |
| # "doc_id": "repdoc", | |
| # "error_count": 0, | |
| # "id": "f4d6f5ea9b59a98faebecde02e68e48b+continuous", | |
| # "info": { | |
| # "changes_pending": null, | |
| # "checkpointed_source_seq": 0, | |
| # "doc_write_failures": 0, | |
| # "docs_read": 1, | |
| # "docs_written": 1, | |
| # "missing_revisions_found": 1, | |
| # "revisions_checked": 1, | |
| # "source_seq": "1-g1AAAACNeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYExlygQLshommFhYWqSkMnKV5KalpmXmpKTg157EASYYGIPUfagYj2AzTpERjA0tDTF1ZANjhI_Q", | |
| # "through_seq": "1-g1AAAACNeJzLYWBgYMpgTmHgz8tPSTV0MDQy1zMAQsMckEQiQ1L9____szKYExlygQLshommFhYWqSkMnKV5KalpmXmpKTg157EASYYGIPUfagYj2AzTpERjA0tDTF1ZANjhI_Q" | |
| # }, | |
| # "last_updated": "2022-02-27T20:41:37Z", | |
| # "node": "[email protected]", | |
| # "source": "http://localhost:15984/source/", | |
| # "source_proxy": null, | |
| # "start_time": "2022-02-27T20:41:37Z", | |
| # "state": "running", | |
| # "target": "http://localhost:15984/target/", | |
| # "target_proxy": null | |
| # } | |
| # ], | |
| # "offset": 0, | |
| # "total_rows": 1 | |
| # } | |
| # + http -b http://adm:pass@localhost:15984/target/_all_docs | |
| # { | |
| # "offset": 0, | |
| # "rows": [ | |
| # { | |
| # "id": "doc1", | |
| # "key": "doc1", | |
| # "value": { | |
| # "rev": "1-4b8a35d3f70a5962f86c6dd06ceb599c" | |
| # } | |
| # } | |
| # ], | |
| # "total_rows": 1 | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment