Skip to content

Instantly share code, notes, and snippets.

@Dougley
Created September 5, 2018 12:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Dougley/263d36f8590d0b62a7c8ff9af480aef4 to your computer and use it in GitHub Desktop.
Save Dougley/263d36f8590d0b62a7c8ff9af480aef4 to your computer and use it in GitHub Desktop.
mongodb backblaze b2 backup
#!/usr/bin/env bash
trap "break;exit" SIGHUP SIGINT SIGTERM
while /bin/true; do
b2 authorize-account ${B2_ACCOUNT_ID} ${B2_ACCESS_KEY}
mongodump --uri ${MONGO_URI} --gzip --archive=/tmp/backup.archive
b2 upload-file --sha1 $(sha1sum /tmp/backup.archive | awk '{print $1}') ${B2_BUCKET} /tmp/backup.archive backup-$(date +%F).archive
sleep 1d
done
FROM mongo
LABEL maintainer="Remco Jongschaap <hello@dougley.com>"
COPY . /opt/b2mongo
WORKDIR /opt/b2mongo
RUN apt update && apt install python3 curl -y
RUN curl https://bootstrap.pypa.io/get-pip.py | python3
RUN pip install --upgrade b2
ENTRYPOINT ["bash", "./backup.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment