Last active
June 14, 2023 20:31
-
-
Save lucis/74954565122710a690bfa5a4c9ca2e9b to your computer and use it in GitHub Desktop.
Mongo DB Backup + Gdrive Upload
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 | |
cd /tmp | |
FILE=`date +%m%d%y%S` | |
DEST=mongodb-backup/$FILE.gz | |
DB_NAME=database-name | |
# This PARENT_FOLDER is a reference to a Google Drive folder in your account (like, "my-backups"). | |
# Use gdrive list to get the ID of the folder you want | |
PARENT_FOLDER=186AdURawhC3qJDL7OkGL9ueJmU44pteV | |
mongodump -d $DB_NAME --archive=$DEST --gzip | |
gdrive --service-account sa.json upload -p $PARENT_FOLDER $DEST | |
ls mongodb-backup | grep -v $FILE.gz | xargs rm |
Thanks @lucis, love how simple this is :)
a more detail would help using this script. how drive works..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please share details to backup