Created
October 8, 2019 18:29
-
-
Save xman1980/c4f8d5e0847ec4cf4b08f8a3b402ea25 to your computer and use it in GitHub Desktop.
backup arangodb to S3
This file contains hidden or 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