Update backup.sh
This commit is contained in:
parent
de814ff56a
commit
05a458f443
19
backup.sh
19
backup.sh
|
@ -29,6 +29,7 @@ db_name="fulldbbackup"
|
|||
#Telegram details
|
||||
api=bot api
|
||||
chatid=chat id info
|
||||
url="https://api.telegram.org/bot$api/sendMessage"
|
||||
|
||||
#ssh info
|
||||
suser="user"
|
||||
|
@ -36,37 +37,37 @@ shost="host/ip"
|
|||
sloc="backup remote location"
|
||||
|
||||
# Print start status message.
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Backing up <b>$backup_files</b> to <b>$dest/$archive_file</b>"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backing up <b>$backup_files</b> to <b>$dest/$archive_file</b>"
|
||||
|
||||
# Backup the files using tar.
|
||||
tar czvfP $dest/$archive_file $backup_files
|
||||
|
||||
# Print end status message.
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup finished at <b>$dest/$archive_file</b>"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup finished at <b>$dest/$archive_file</b>"
|
||||
|
||||
# Copy over ssh
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Copy backup <b>$archive_file</b> to orangepi"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Copy backup <b>$archive_file</b> to orangepi"
|
||||
|
||||
scp $dest/$archive_file $suser@$shost:$sloc
|
||||
|
||||
#finished copy
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup <b>$archive_file<b> to orangepi complete"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup <b>$archive_file<b> to orangepi complete"
|
||||
|
||||
#Start database backup
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Starting SQL Backup"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Starting SQL Backup"
|
||||
|
||||
#dump database
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="dump database"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="dump database"
|
||||
|
||||
mysqldump --user=$user --events --ignore-table=mysql.event --password=$password --all-databases > $dest/$db_name-$date.sql
|
||||
|
||||
#make tar
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup the files using tar."
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup the files using tar."
|
||||
|
||||
tar -cpzf $dest/$sql_file --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=$dest $src_dir
|
||||
|
||||
# Copy over ssh
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Copy backup to orangepi"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Copy backup to orangepi"
|
||||
|
||||
scp $dest/$sql_file $suser@$shost:$sloc
|
||||
|
||||
|
@ -76,7 +77,7 @@ uptime >> /tmp/backup/info2
|
|||
uname=`cat /tmp/backup/info1`
|
||||
uptime=`cat /tmp/backup/info2`
|
||||
|
||||
curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d parse_mode="HTML" -d text="Current uptime of <b>$uname</b> is <b>$uptime</b>. All backups complete, good bye! :)"
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Current uptime of <b>$uname</b> is <b>$uptime</b>. All backups complete, good bye! :)"
|
||||
|
||||
#delete files
|
||||
rm $dest/$archive_file
|
||||
|
|
Loading…
Reference in New Issue