mysql backup script
This commit is contained in:
commit
ce28d7c574
2
README.md
Normal file
2
README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# sarmic
|
||||||
|
- I will be adding any useful scripts, oneliners, wikis and whatnot I find here.
|
20
backupdb.sh
Executable file
20
backupdb.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#import credentials
|
||||||
|
source .env
|
||||||
|
|
||||||
|
#
|
||||||
|
DATETIME="$(date +'%d-%m-%Y_%H:%M:%S')"
|
||||||
|
GZFILE=$DB_DATABASE-$DATETIME.sql.gz
|
||||||
|
|
||||||
|
#change working directory to temporary
|
||||||
|
cd /tmp/
|
||||||
|
|
||||||
|
#dump the database to compressed .sql.gz file
|
||||||
|
mysqldump --opt --user=$DB_USERNAME --password=$DB_PASSWORD $DB_DATABASE | gzip > $GZFILE
|
||||||
|
|
||||||
|
#send to gzip file to telegram
|
||||||
|
curl -s -F document=@$GZFILE https://api.telegram.org/bot$TG_BOT_TOKEN/sendDocument?chat_id=$TG_CHATID
|
||||||
|
|
||||||
|
#delete .gzip file
|
||||||
|
rm $GZFILE
|
Loading…
x
Reference in New Issue
Block a user