Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b6f635386 | ||
|
|
cfb9e508da | ||
|
|
1d25c671bb | ||
|
|
77c64b4045 | ||
|
|
30c4905d71 | ||
|
|
94221b71ce |
@@ -21,9 +21,10 @@ mysql:backup <name> <bucket> (--use-iam) Create a backup of the mysql service to
|
||||
mysql:backup-auth <name> <aws_access_key_id> <aws_secret_access_key> (<aws_default_region>) (<aws_signature_version>) (<endpoint_url>) Sets up authentication for backups on the mysql service
|
||||
mysql:backup-deauth <name> Removes backup authentication for the mysql service
|
||||
mysql:backup-schedule <name> <schedule> <bucket> Schedules a backup of the mysql service
|
||||
mysql:backup-set-encryption <name> <encryption_key>, Sets up GPG encryption for future backups of the mysql service
|
||||
mysql:backup-schedule-cat <name> Cat the contents of the configured backup cronfile for the service
|
||||
mysql:backup-set-encryption <name> <encryption_key> Sets up GPG encryption for future backups of the mysql service
|
||||
mysql:backup-unschedule <name> Unschedules the backup of the mysql service
|
||||
mysql:backup-unset-encryption <name>, Removes backup encryption for future backups of the mysql service
|
||||
mysql:backup-unset-encryption <name> Removes backup encryption for future backups of the mysql service
|
||||
mysql:clone <name> <new-name> Create container <new-name> then copy data from <name> into <new-name>
|
||||
mysql:connect <name> Connect via mysql to a mysql service
|
||||
mysql:create <name> Create a mysql service with environment variables
|
||||
@@ -217,6 +218,9 @@ dokku mysql:backup lolipop BUCKET_NAME
|
||||
# CRON_SCHEDULE is a crontab expression, eg. "0 3 * * *" for each day at 3am
|
||||
dokku mysql:backup-schedule lolipop CRON_SCHEDULE BUCKET_NAME
|
||||
|
||||
# cat the contents of the configured backup cronfile for the service
|
||||
dokku mysql:backup-schedule-cat lolipop
|
||||
|
||||
# remove the scheduled backup from cron
|
||||
dokku mysql:backup-unschedule lolipop
|
||||
```
|
||||
|
||||
@@ -59,7 +59,7 @@ is_container_status() {
|
||||
declare desc="Returns 0 or 1 depending upon whether a given container has a certain status"
|
||||
declare CID="$1" STATUS="$2"
|
||||
local TEMPLATE="{{.State.$STATUS}}"
|
||||
local CONTAINER_STATUS=$(docker inspect -f "$TEMPLATE" "$CID" || true)
|
||||
local CONTAINER_STATUS=$(docker inspect -f "$TEMPLATE" "$CID" 2> /dev/null || true)
|
||||
|
||||
if [[ "$CONTAINER_STATUS" == "true" ]]; then
|
||||
return 0
|
||||
@@ -196,6 +196,18 @@ service_backup_schedule() {
|
||||
sudo /bin/chmod 644 "$CRON_FILE"
|
||||
}
|
||||
|
||||
service_backup_schedule_cat() {
|
||||
declare desc="cat the contents of the configured backup cronfile for the service"
|
||||
declare SERVICE="$1"
|
||||
local CRON_FILE="/etc/cron.d/dokku-${PLUGIN_COMMAND_PREFIX}-${SERVICE}"
|
||||
|
||||
if [[ ! -f "$CRON_FILE" ]]; then
|
||||
dokku_log_fail "There is no scheduled backup for ${SERVICE}."
|
||||
fi
|
||||
|
||||
cat "$CRON_FILE"
|
||||
}
|
||||
|
||||
service_backup_unschedule() {
|
||||
declare desc="unschedules the backup of the service"
|
||||
declare SERVICE="$1"
|
||||
@@ -375,8 +387,10 @@ service_logs() {
|
||||
DOKKU_LOGS_ARGS="--follow"
|
||||
fi
|
||||
|
||||
is_container_status "$ID" "Running" || dokku_log_warn "Service logs may not be output as service is not running"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker logs $DOKKU_LOGS_ARGS "$ID"
|
||||
docker logs $DOKKU_LOGS_ARGS "$ID" 2> /dev/null
|
||||
}
|
||||
|
||||
service_parse_args() {
|
||||
@@ -553,13 +567,17 @@ service_status() {
|
||||
declare SERVICE="$1"
|
||||
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||
local CONTAINER_STATUS
|
||||
|
||||
is_container_status "$ID" "Dead" && echo "dead" && return 0
|
||||
is_container_status "$ID" "OOMKilled" && echo "oomkilled" && return 0
|
||||
is_container_status "$ID" "Paused" && echo "paused" && return 0
|
||||
is_container_status "$ID" "Restarting" && echo "restarting" && return 0
|
||||
is_container_status "$ID" "Running" && echo "running" && return 0
|
||||
echo "stopped" && return 0
|
||||
|
||||
CONTAINER_STATUS=$(docker inspect -f "{{.State.Status}}" "$CID" 2> /dev/null || true)
|
||||
[[ -n "$CONTAINER_STATUS" ]] && echo "$CONTAINER_STATUS" && return 0
|
||||
echo "missing" && return 0
|
||||
}
|
||||
|
||||
service_stop() {
|
||||
@@ -608,7 +626,7 @@ service_version() {
|
||||
declare desc="Displays the running version for an image"
|
||||
declare SERVICE="$1"
|
||||
local SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||
docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME"
|
||||
docker inspect -f '{{.Config.Image}}' "$SERVICE_NAME" 2> /dev/null || true
|
||||
}
|
||||
|
||||
update_plugin_scheme_for_app() {
|
||||
|
||||
2
config
2
config
@@ -11,6 +11,8 @@ export PLUGIN_DATA_HOST_ROOT=$MYSQL_HOST_ROOT
|
||||
export PLUGIN_DATASTORE_PORTS=(3306)
|
||||
export PLUGIN_DATASTORE_WAIT_PORT=3306
|
||||
export PLUGIN_DEFAULT_ALIAS="DATABASE"
|
||||
export PLUGIN_DISABLE_PULL=${MYSQL_DISABLE_PULL:=}
|
||||
export PLUGIN_DISABLE_PULL_VARIABLE="MYSQL_DISABLE_PULL"
|
||||
export PLUGIN_ALT_ALIAS="DOKKU_MYSQL"
|
||||
export PLUGIN_IMAGE=$MYSQL_IMAGE
|
||||
export PLUGIN_IMAGE_VERSION=$MYSQL_IMAGE_VERSION
|
||||
|
||||
@@ -30,8 +30,8 @@ service_create() {
|
||||
service_parse_args "${@:2}"
|
||||
|
||||
if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then
|
||||
if [[ "$MYSQL_DISABLE_PULL" == "true" ]]; then
|
||||
dokku_log_warn "MYSQL_DISABLE_PULL environment variable detected. Not running pull command." 1>&2
|
||||
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||
dokku_log_warn "${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||
dokku_log_warn " docker pull ${IMAGE}" 1>&2
|
||||
dokku_log_warn "$PLUGIN_SERVICE service creation failed"
|
||||
exit 1
|
||||
|
||||
4
install
4
install
@@ -5,8 +5,8 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||
plugin-install() {
|
||||
pull-docker-image() {
|
||||
declare IMAGE="$1"
|
||||
if [[ "$MYSQL_DISABLE_PULL" == "true" ]]; then
|
||||
echo " ! MYSQL_DISABLE_PULL environment variable detected. Not running pull command." 1>&2
|
||||
if [[ "$PLUGIN_DISABLE_PULL" == "true" ]]; then
|
||||
echo " ! ${PLUGIN_DISABLE_PULL_VARIABLE} environment variable detected. Not running pull command." 1>&2
|
||||
echo " ! docker pull ${IMAGE}" 1>&2
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku mysql service plugin"
|
||||
version = "1.1.0"
|
||||
version = "1.2.1"
|
||||
[plugin.config]
|
||||
|
||||
20
subcommands/backup-schedule-cat
Executable file
20
subcommands/backup-schedule-cat
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/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-backup-schedule-cat-cmd() {
|
||||
#E cat the contents of the configured backup cronfile for the service
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:backup-schedule-cat lolipop
|
||||
#A service, service to run command against
|
||||
declare desc="cat the contents of the configured backup cronfile for the service"
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:backup-schedule-cat" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1"
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$SERVICE"
|
||||
service_backup_schedule_cat "$SERVICE"
|
||||
}
|
||||
|
||||
service-backup-schedule-cat-cmd "$@"
|
||||
Reference in New Issue
Block a user