Skip to content

Commit

Permalink
Merge pull request #47 from odra/INTLY-2167_redis-save
Browse files Browse the repository at this point in the history
backend redis bgsave
  • Loading branch information
odra committed May 30, 2019
2 parents d8367f3 + a8e66d1 commit f4e1e20
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
16 changes: 16 additions & 0 deletions image/tools/lib/component/3scale-redis.sh
Original file line number Diff line number Diff line change
@@ -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}"
}

0 comments on commit f4e1e20

Please sign in to comment.