Created
September 5, 2018 12:50
-
-
Save Dougley/263d36f8590d0b62a7c8ff9af480aef4 to your computer and use it in GitHub Desktop.
mongodb backblaze b2 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
#!/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 |
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
FROM mongo | |
LABEL maintainer="Remco Jongschaap <[email protected]>" | |
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