diff --git a/image/Dockerfile b/image/Dockerfile index 5ed7cb2..0217e4b 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -7,6 +7,7 @@ RUN yum --enablerepo=extras install -y epel-release && \ yum install -y https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm && \ yum install -y postgresql96 && \ yum install -y postgresql10 && \ + yum install -y redis && \ yum clean all && \ pip install -U pip && \ pip install awscli s3cmd && \ diff --git a/image/tools/lib/component/3scale-redis.sh b/image/tools/lib/component/3scale-redis.sh index 716d1cd..e132b0f 100644 --- a/image/tools/lib/component/3scale-redis.sh +++ b/image/tools/lib/component/3scale-redis.sh @@ -1,9 +1,25 @@ +function get_redis_host { + echo "`oc get secret ${COMPONENT_SECRET_NAME} -n ${COMPONENT_SECRET_NAMESPACE} -o jsonpath={.data.REDIS_HOST} | base64 --decode`" +} + +function save { + local host="$(get_redis_host)" + local lastsave="$(redis-cli -h ${host} lastsave)" + redis-cli -h ${host} bgsave + + while [ "$lastsave" -eq "$(redis-cli -h ${host} lastsave)" ]; do + sleep 5 + done +} + function component_dump_data { + save local ts=$(date '+%H_%M_%S') dest_file="$1/archives/dump-${ts}.rdb" dump_rdb_path="/var/lib/redis/data/dump.rdb" oc projects redis_pod_name=$(oc get pods -l deploymentConfig=backend-redis -o name -n ${PRODUCT_NAMESPACE_PREFIX}3scale | sed -e 's/^pod\///') + cp_pod_data "${PRODUCT_NAMESPACE_PREFIX}3scale/${redis_pod_name}:${dump_rdb_path}" "${dest_file}" } \ No newline at end of file