From 266bd82600f0c800f32bf7f7be1a5b46850d3adb Mon Sep 17 00:00:00 2001 From: infernvs Date: Wed, 18 Oct 2017 11:51:03 +0100 Subject: [PATCH] change some stuff --- backup.sh | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/backup.sh b/backup.sh index 5f125fc..d431d1b 100644 --- a/backup.sh +++ b/backup.sh @@ -20,6 +20,21 @@ archive_file="$hostname-$day.tgz" api=bot api chatid=chat id info +#Archive Filename +date=`date +%d-%b-%Y` +sql_file="sql_backup-$date.tgz" +src_dir="/tmp/backup" + +#Database info +user="root" +password="change.me" +db_name="fulldbbackup" + +#ssh info +suser=user +shost=host +sloc=ssh host location + # Print start status message. curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d text="Backing up $backup_files to $dest/$archive_file" @@ -33,7 +48,7 @@ curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid # Copy over ssh curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d text="Copy backup $archive_file to orangepi" -scp $dest/$archive_file user@host:~/backups +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 text="Backup $archive_file to orangepi complete" @@ -47,15 +62,6 @@ curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid #Start database backup curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d text="Starting SQL Backup" -#Archive Filename -date=`date +%d-%b-%Y` -sql_file="sql_backup-$date.tgz" -src_dir="/tmp/backup" - -#Database info -user="root" -password="change.me" -db_name="fulldbbackup" #dump database curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d text="dump database" @@ -73,7 +79,7 @@ rm $dest/$db_name-$date.sql # Copy over ssh curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d text="Copy backup to orangepi" -scp $dest/$sql_file user@host:~/backups +scp $dest/$sql_file $suser@$shost:$sloc #delete sql tar file rm $dest/$sql_file @@ -84,7 +90,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 text="Current uptime of $uname is $uptime. All backups complete, good bye!" +curl -s -X POST https://api.telegram.org/bot$api/sendMessage -d chat_id=$chatid -d text="Current uptime of $uname is $uptime. All backups complete, good bye! :)" rm /tmp/backup/info1 rm /tmp/backup/info2 #done \ No newline at end of file