Skip to content

Commit

Permalink
Merge pull request #11 from matskiv/INTLY-1000
Browse files Browse the repository at this point in the history
INTLY-1000 - add redis backup component
  • Loading branch information
odra authored Mar 4, 2019
2 parents af72f91 + 0e4148a commit e18c1cf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion image/tools/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ DATESTAMP=$(date '+%Y/%m/%d')
DEST=/tmp/intly
ARCHIVES_DEST=$DEST/archives
mkdir -p $DEST $ARCHIVES_DEST
export HOME=$DEST

component_dump_data $DEST
echo '==> Component data dump completed'

export HOME=$DEST
if [[ "$encryption_engine" ]]; then
encrypt_prepare $DEST
encrypted_files="$(encrypt_archive $ARCHIVES_DEST)"
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
@@ -0,0 +1,16 @@
function component_dump_data {
dest_file="$1/archives/dump.rdb"
dumb_rdb_path="/var/lib/redis/data/dump.rdb"

oc projects
redis_pod_name=$(oc get pods -l deploymentConfig=backend-redis -o name -n 3scale | sed -e 's/^pod\///')
copy_output=$(oc cp 3scale/${redis_pod_name}:${dumb_rdb_path} ${dest_file})
echo ${copy_output}

# check if rdb file was rewritten during oc cp, and copy it again if it was
if [[ $copy_output == *"file changed as we read it"* ]]; then
sleep 10s #wait until rdb rewrite finished
echo "dumb.rdb has been overwritten during copying, executing 'oc cp' again"
oc cp 3scale/${redis_pod_name}:${dumb_rdb_path} ${dest_file}
fi
}
6 changes: 6 additions & 0 deletions templates/openshift/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ rules:
- apiGroups: ['*']
resources: ['*']
verbs: ['get', 'list']
- apiGroups:
- ['']
resources:
- ['pods/exec']
verbs:
- ['create']

0 comments on commit e18c1cf

Please sign in to comment.