Last active
June 21, 2016 09:14
-
-
Save tralamazza/5311639 to your computer and use it in GitHub Desktop.
call bgsave and sleep 5 loop until lastsave changes
upload backup rdb to S3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rediscli=`which redis-cli` | |
s3cmd=`which s3cmd` | |
lsave=`$rediscli lastsave` | |
echo "LASTSAVE $lsave" | |
saved="`$rediscli config get dir | xargs | cut -d ' ' -f 2`/`$rediscli config get dbfilename | xargs | cut -d ' ' -f 2`" | |
$rediscli bgsave | |
while [ $lsave -eq `$rediscli lastsave` ]; do | |
sleep 5 | |
done | |
echo "LASTSAVE `$rediscli lastsave`" | |
echo "BGSAVE complete! ($saved)" | |
s3bucket="${1:-<YOURBUCKET>}" | |
s3filepath="${2:-/backups/redis/backup.rdb}" | |
$s3cmd put $saved s3://$s3bucket/$s3filepath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great, thanks for sharing!