Skip to content

Instantly share code, notes, and snippets.

@creativefull
Created February 26, 2018 07:48
Show Gist options
  • Select an option

  • Save creativefull/55b34853afce58ee84d70cd15f4d4685 to your computer and use it in GitHub Desktop.

Select an option

Save creativefull/55b34853afce58ee84d70cd15f4d4685 to your computer and use it in GitHub Desktop.
Auto Backup push git
#!/bin/sh
DIR=`date +%m%d%y`
INITHOME=/home/server/backup/db-smart
DEST=$INITHOME/$DIR
mkdir -p $DEST
# MULAI BACKUP
mongodump -h localhost --port=29000 -d smart -o $DEST
# KIRIM PESAN KE SLACK
curl -X POST -H 'Content-type: application/json' --data '{"text":"System anda sudah berhasil backup data di folder '$DEST' :kissing_heart: "}' https://hooks.slack.com/services/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
echo "Cloud auto backup"
cd $INITHOME
git pull origin master
git add -A
git commit -m "add new backup $DIR"
git push -u origin master
echo "BERHASIL MENYIMPAN BACKUP KE REPOSITORY $DIR"
# kirim pesan ke slack
curl -X POST -H 'Content-type: application/json' --data '{"text":"Backup database anda sudah masuk ke cloud :smirk:"}' https://hooks.slack.com/services/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment