How to copy a couch to the dock

I want to take a snapshot of one database running in an application wwwand put it in the application staging. When I do this using cloning or creating / importing, none of the data is available.

How am I supposed to do this?

matt@server:~$ dokku run www curl http://www:password@dokku-couchdb-www:5555/www

{"db_name":"www","doc_count":4966,"doc_del_count":232,"update_seq":46475,"purge_seq":0,"compact_running":false,"disk_size":3071180923,"data_size":334987077,"instance_start_time":"1500006610823893","disk_format_version":6,"committed_update_seq":46475}

So from this you see 4966 documents.

matt@server:~$ dokku couchdb:clone www staging_www
-----> Starting container
       Waiting for container to be ready
=====> CouchDB container created: staging_www
       DSN: http://staging_www:password@dokku-couchdb-staging-www:5555/staging_www
-----> Copying data from www to staging_www
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                                                                                                Dload  Upload   Total   Spent    Left  Speed
100 1110M    0 1110M    0     0  30.4M      0 --:--:--  0:00:36 --:--:-- 31.9M
                                                                              -----> Done

Thus, there are no errors in the clone. Then i ran

dokku couchdb:link staging_www staging
dokku couchdb:promote staging_www staging

And there are no errors, but if I check the DB:

matt@server:~$ dokku run staging curl http://staging_www:password@dokku-couchdb-staging-www:5555/staging_www
{"db_name":"staging_www","doc_count":1,"doc_del_count":0,"update_seq":1,"purge_seq":0,"compact_running":false,"disk_size":4188,"data_size":342,"instance_start_time":"1509536857606369","disk_format_version":6,"committed_update_seq":1}

The document counter is 1, and I can’t access any data in the application staging.

I tried equally

dokku couchdb:export www > www.couch
dokku couchdb:create staging_www
dokku couchdb:import staging_www < www.couch
dokku couchdb:link staging_www staging
dokku couchdb:promote staging_www staging

There are no errors, but again I get 1 document in the database.

What should I do?

+4
source share
2 answers

With dokku 0.9.4 and 'dokku couchdb service plugin' 1.0.0

.

root@dokku01:~# dokku couchdb:clone www staging_www

db. staging_www

root@dokku01:~# dokku couchdb:destroy staging_www

.

root@dokku01:~# dokku couchdb:clone www staging_www

, . db

root@dokku01:~# curl -X GET 'http://staging_www:password@dokku-couchdb-staging-www:5555/staging_www/_all_docs?include_docs=true&attachments=true'

www, staging_www .

CouchDB, .

UPDATE

bash script "couchdb-backup". "" script db, .

Cloning db: , ( ) , () db.

Script "clone" script couchdb. "couchdb-backup".

#!/usr/bin/env bash
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_BASE_PATH/common/functions"
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"

service-clone-cmd() {
  #E you can clone an existing service to a new one
  #E dokku $PLUGIN_COMMAND_PREFIX:clone lolipop lolipop-2
  #A service, service to run command against
  #A new-service, name of new service
  declare desc="create container <new-name> then copy data from <name> into <new-name>"
  local cmd="$PLUGIN_COMMAND_PREFIX:clone" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
  declare SERVICE="$1" NEW_SERVICE="$2" CLONE_FLAGS_LIST="${@:3}"

  [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
  [[ -z "$NEW_SERVICE" ]] && dokku_log_fail "Please specify a name for the new service"
  verify_service_name "$SERVICE"

  PLUGIN_IMAGE=$(service_version "$SERVICE" |  grep -o "^.*:" | sed -r "s/://g")
  PLUGIN_IMAGE_VERSION=$(service_version "$SERVICE" |  grep -o ":.*$" | sed -r "s/://g")

  service_create "$NEW_SERVICE" "${@:3}"
  dokku_log_info1 "Copying data from $SERVICE to $NEW_SERVICE"

attempts=5
attemptcount=0
R=2
succ_str=' Successfully.'
until [[ $R = 0 || $R = 1 ]]; do
  attemptcount=$((attemptcount+1))
  STDOUT1=$(service_export "$SERVICE" | service_import "$NEW_SERVICE" 2>&1) || true
  if [[ ! "$STDOUT1" = *"${succ_str}" ]]; then
    if [ $attemptcount = $attempts ]; then
      R=1
      echo -e "\nERROR: CouchDB Import failed - Stopping\n"
    else
      echo -e "\nWARN: CouchDB Import Reported an error - Attempt ${attemptcount}/${attempts} - Retrying...\n"
      sleep 1
    fi
  else
    R=0
  fi
done
dokku_log_info1 "Done"
exit $R
}

service-clone-cmd "$@"

/var/lib/dokku/plugins/available/couchdb/subcommands/clone .

0

dokku couchdb

Curl , . peasy

-1

Source: https://habr.com/ru/post/1688529/


All Articles