diff --git a/backup.sh b/backup.sh index ed88cb3..184ca63 100644 --- a/backup.sh +++ b/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 $backup_files to $dest/$archive_file" +curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backing up $backup_files to $dest/$archive_file" # 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 $dest/$archive_file" +curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup finished at $dest/$archive_file" # 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 $archive_file to orangepi" +curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Copy backup $archive_file 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 $archive_file to orangepi complete" +curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backup $archive_file 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 $uname is $uptime. All backups complete, good bye! :)" +curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Current uptime of $uname is $uptime. All backups complete, good bye! :)" #delete files rm $dest/$archive_file