Copied code from the bash framework and add json based config file support

This commit is contained in:
kake26 2023-12-09 22:37:59 -06:00
parent 3ccf356c11
commit 6d893a43a6
3 changed files with 78 additions and 10 deletions

View file

@ -1,23 +1,33 @@
#!/bin/bash
# Another OpenWrt bash script
set -eo pipefail # you cann add u into -eo, but it drives me nuts so I won't
if [[ -n "${BASHD_DEBUG}" ]]; then # a inevitability that this will be used
set -x
fi
trap cleanup EXIT # A little more robust cleanup
cleanup() {
# We can clean up any temp files or what nots, but for now a place holder
true
}
source ./config.bash
# Run backups via restic
bkpwd="yourbackuppasswordhere" # We are gonna need that
bkpwd=$(read_json "$JSON_FILE" "restic" "password")
export RESTIC_PASSWORD="$bkpwd"
# resticbasecmd = "restic -r sftp:restic@192.168.1.113:/home/restic backup" # root ssh key must be setup to access the remote target
# OpenWrt uses dropbear so use dropbear's key gen
# Stuff to backup
# Two dirs I want to keep backed up
/usb/scripts/bin/restic -r sftp:pi@192.168.1.168:/storage/backup/openwrt backup /etc
/usb/scripts/bin/restic -r sftp:nbak@192.168.1.168:/storage/backup/openwrt backup /etc
curl -d "ETC backed up" 192.168.1.168:83/openwrt_backup
/usb/scripts/bin/restic -r sftp:pi@192.168.1.168:/storage/backup/openwrt backup /usb/scripts
/usb/scripts/bin/restic -r sftp:nbak@192.168.1.168:/storage/backup/openwrt backup /usb/scripts
curl -d "Scripts backed up" 192.168.1.168:83/openwrt_backup
/usb/scripts/bin/restic -r sftp:pi@192.168.1.168:/storage/backup/openwrt backup /root
/usb/scripts/bin/restic -r sftp:nbak@192.168.1.168:/storage/backup/openwrt backup /root
curl -d "Root backed up" 192.168.1.168:83/openwrt_backup
/usb/scripts/bin/restic -r sftp:pi@192.168.1.168:/storage/backup/openwrt backup /usb/vnstat/vnstat.db
/usb/scripts/bin/restic -r sftp:nbak@192.168.1.168:/storage/backup/openwrt backup /usb/vnstat/vnstat.db
curl -d "Vnstat backed up" 192.168.1.168:83/openwrt_backup