Created
March 3, 2014 08:06
-
-
Save calston/9320470 to your computer and use it in GitHub Desktop.
Riak S3 backup
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 | |
bucket="ChangeMe" | |
if [ -e "/usr/bin/s3cmd" ]; then | |
s3cmd="/usr/bin/s3cmd" | |
else | |
s3cmd="/usr/local/bin/s3cmd" | |
fi | |
date=`/bin/date +"%Y-%m-%d"` | |
function syncs3() { | |
bsize=`stat -c '%s' $1` | |
if [ "${bsize}" -le "2147483648" ]; then | |
$s3cmd sync "$1" s3://$bucket/$date/ | |
else | |
# never more than 2G files | |
cd `dirname $1` | |
split -d -b 2G "$1" `basename $1`-split. | |
find . -name "`basename $1`*-split.*" -exec $s3cmd sync {} s3://$bucket/$date/ \; | |
fi | |
} | |
rm -f /mnt/riak.tar.gz | |
/etc/init.d/riak stop | |
chmod a-x /etc/init.d/riak | |
cd /var/lib/riak | |
tar -zphcf /mnt/riak.tar.gz /var/lib/riak | |
chmod a+x /etc/init.d/riak | |
/etc/init.d/riak start | |
syncs3 /mnt/riak.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment