Skip to content

Commit f6e418a

Browse files
authored
Merge pull request #190 from github/flexible-redis-cli
Add support for both ghe-redis-cli and redis-cli
2 parents 223ff24 + 8100fb6 commit f6e418a

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

share/github-backup-utils/ghe-backup-redis

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,29 @@ ghe_remote_version_required "$GHE_HOSTNAME"
2121
ghe-ssh "$GHE_HOSTNAME" /bin/bash <<EOF
2222
set -e
2323
24+
if which ghe-redis-cli > /dev/null; then
25+
redis_cli=ghe-redis-cli
26+
redis_arg=--remote
27+
else
28+
redis_cli=redis-cli
29+
redis_arg=
30+
fi
2431
redis_host=\$(ghe-config cluster.redis-master 2>/dev/null || echo "localhost")
25-
timestamp=\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)
32+
timestamp=\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)
2633
2734
for i in \$(seq 10); do
28-
if ! ghe-redis-cli --remote -h \$redis_host BGSAVE | grep -q ERR; then
35+
if ! \$redis_cli \$redis_arg -h \$redis_host BGSAVE | grep -q ERR; then
2936
break
3037
fi
3138
sleep 15
3239
done
3340
for n in \$(seq 3600); do
34-
if [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then
41+
if [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then
3542
break
3643
fi
3744
sleep 1
3845
done
39-
[ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work
46+
[ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work
4047
4148
if [ "\$redis_host" != "localhost" ]; then
4249
ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb'

0 commit comments

Comments
 (0)