27 lines
1.1 KiB
Bash
Executable File
27 lines
1.1 KiB
Bash
Executable File
#!/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"
|
|
|
|
redis-clone-cmd() {
|
|
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"
|
|
|
|
[[ -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"
|
|
service_export "$SERVICE" | service_import "$NEW_SERVICE" > /dev/null 2>&1 || true
|
|
dokku_log_info1 "Done"
|
|
}
|
|
|
|
redis-clone-cmd "$@"
|