Add 'backup_borg.sh'
This commit is contained in:
parent
a4164cabc2
commit
f886e1825e
|
@ -0,0 +1,53 @@
|
|||
#!/bin/csh
|
||||
#HOME=/root
|
||||
#LOGNAME=root
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
#LANG=en_US.UTF-8
|
||||
SHELL=/bin/sh
|
||||
#PWD=/root
|
||||
#######################################
|
||||
# #
|
||||
# Backup script for FreeBSD #
|
||||
# using restic & telegram messages #
|
||||
# #
|
||||
#######################################
|
||||
|
||||
# Folders to backup
|
||||
backup_files="files/folders to backup"
|
||||
|
||||
# Where to backup.
|
||||
dest="destination backup"
|
||||
sshuser="user"
|
||||
sshhost="host"
|
||||
# Fill in your password here, borg picks it up automatically
|
||||
export BORG_PASSPHRASE="borg_respository_pw"
|
||||
#Telegram details
|
||||
api=telegram_bot_api
|
||||
chatid=chat_id
|
||||
url="https://api.telegram.org/bot$api/sendMessage"
|
||||
|
||||
# Print start status message.
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="Backing up <b>$backup_files</b> to <b>$sshhost/$dest</b>"
|
||||
|
||||
#starting borg backup
|
||||
borg create --progress --stats --compression lz4 --exclude-caches --exclude '/home/*/.cache/*' $sshuser@$sshhost:$dest::'{hostname}-{now}' $backup_files
|
||||
|
||||
borg prune -v --list --keep-daily 1 $sshuser@$sshhost:$dest
|
||||
|
||||
#restic -r sftp:$sshuser@$sshhost:$dest -p /root/pw snapshots >> /tmp/backup/ss
|
||||
borg list $sshuser@$sshhost:$dest >> /tmp/backup/ss
|
||||
|
||||
uname -onr >> /tmp/backup/info1
|
||||
uptime >> /tmp/backup/info2
|
||||
|
||||
uname=`cat /tmp/backup/info1`
|
||||
uptime=`cat /tmp/backup/info2`
|
||||
snapshots=`cat /tmp/backup/ss`
|
||||
|
||||
curl -s -X POST $url -d chat_id=$chatid -d parse_mode="HTML" -d text="<b>Current backups</b>%0A %0A $snapshots%0A %0A Current uptime of %0A <b>$uname</b> is %0A %0A <b>$uptime</b>"
|
||||
|
||||
#delete files
|
||||
rm /tmp/backup/info1
|
||||
rm /tmp/backup/info2
|
||||
rm /tmp/backup/ss
|
||||
#done
|
Loading…
Reference in New Issue