Skip to content

Instantly share code, notes, and snippets.

@faruken
Created July 21, 2017 04:14
Show Gist options
  • Save faruken/c7acf325b98d8730391093abe3e613d6 to your computer and use it in GitHub Desktop.
Save faruken/c7acf325b98d8730391093abe3e613d6 to your computer and use it in GitHub Desktop.
backup arangodb to S3
#!/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