-
Notifications
You must be signed in to change notification settings - Fork 231
/
dbbackupwizwiz.sh
21 lines (15 loc) · 1.02 KB
/
dbbackupwizwiz.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
telegramBotToken=$(cat /var/www/html/wizwizxui-timebot/baseInfo.php | grep '$botToken' | cut -d"'" -f2)
telegramBotToken2=$(cat /var/www/html/wizwizxui-timebot/baseInfo.php | grep '$botToken' | cut -d'"' -f2)
filepath="/var/www/html/wizwizxui-timebot/baseInfo.php"
chatID=$(cat $filepath | grep '$admin =' | sed 's/.*= //' | sed 's/;//')
databaseUser=$(cat /var/www/html/wizwizxui-timebot/baseInfo.php | grep '$dbUserName' | cut -d"'" -f2)
databasePassword=$(cat /var/www/html/wizwizxui-timebot/baseInfo.php | grep '$dbPassword' | cut -d"'" -f2)
databaseName=$(cat /var/www/html/wizwizxui-timebot/baseInfo.php | grep '$dbName' | cut -d"'" -f2)
backupDir='/tmp/db_backup'
mkdir -p $backupDir
backupFilename="wizwiz_$(date +'%Y-%m-%d_%H-%M-%S').sql"
mysqldump -u$databaseUser -p$databasePassword $databaseName > $backupDir/$backupFilename
telegramAPI="https://api.telegram.org/bot$telegramBotToken/sendDocument"
curl -F "chat_id=$chatID" -F "document=@$backupDir/$backupFilename" "$telegramAPI"
rm "$backupDir/$backupFilename"