Created
July 21, 2017 04:14
-
-
Save faruken/c7acf325b98d8730391093abe3e613d6 to your computer and use it in GitHub Desktop.
backup arangodb 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/sh | |
# Slightly modified to meet ArangoDB's needs. https://github.com/lumerit/s3-shell-backups | |
NOWDATE=`date +%Y-%m-%d` | |
LASTDATE=$(date +%Y-%m-%d --date='1 week ago') | |
USERNAME="${ARANGODB_USERNAME}" | |
PASSWORD="${ARANGODB_PASSWORD}" | |
DATABASE='dbname' | |
SRCDIR='/opt/s3backups' | |
DESTDIR='destdir' | |
BUCKET='bucket' | |
if [ -z "${USERNAME}" ]; then | |
echo "arangodb username is not set" >&2 | |
exit 1 | |
fi | |
if [ -z "${PASSWORD}" ]; then | |
echo "arangodb password is not set" >&2 | |
exit 1 | |
fi | |
mkdir -p $SRCDIR/$NOWDATA-arangodump | |
arangodump --output-directory "$SRCDIR/$NOWDATE-arangodump" --include-system-collections false --server.username "$USERNAME" --server.password "$PASSWORD" --server.database "$DATABASE" | |
tar -zcvf $SRCDIR/$NOWDATE-arangodump.tar.gz $SRCDIR/$NOWDATE-arangodump | |
# copy to S3 | |
aws s3 cp $SRCDIR/$NOWDATE-arangodump.tar.gz s3://$BUCKET/$DESTDIR/ | |
# Delete old backups from S3 | |
aws s3 rm s3://$BUCKET/$DESTDIR/$LASTDATE-arangodump.tar.gz | |
# Remove temp files | |
rm -rf $SRCDIR/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment