53 lines
1.6 KiB
Bash
53 lines
1.6 KiB
Bash
#!/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 borg & 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
|
|
|
|
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
|