70 lines
3.1 KiB
Bash
70 lines
3.1 KiB
Bash
#!/bin/bash
|
|
|
|
# To backup opnsense router with zenarmor, encrypt the root password via clevis and tang and place it here and then copy the backup commands
|
|
|
|
# Variables
|
|
export PBS_PASSWORD_FILE=/root/GauntPBS01-Local.pw
|
|
GauntRouter01EncryptedRootPassword=""
|
|
TheGauntsRouterEncryptedRootPassword=""
|
|
GauntNASEncryptedRootPassword=""
|
|
SSHFSMountDirectory="/mnt/sshfs"
|
|
|
|
if [ ! -d "${SSHFSMountDirectory}" ]; then
|
|
# create the directory
|
|
/usr/bin/mkdir "${SSHFSMountDirectory}" || exit 1
|
|
fi
|
|
|
|
# Backup GauntRouter01
|
|
DNSName="gauntrouter01.home.johnhgaunt.com"
|
|
GauntRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
|
/usr/bin/mkdir ${GauntRouterSSHFSMountDirectory} && \
|
|
/usr/bin/echo ${GauntRouter01EncryptedRootPassword} | \
|
|
/usr/bin/clevis decrypt | \
|
|
/usr/bin/sshfs -o password_stdin -o ro \
|
|
root@${DNSName}:/ ${GauntRouterSSHFSMountDirectory} && \
|
|
/usr/bin/proxmox-backup-client backup \
|
|
conf.pxar:${GauntRouterSSHFSMountDirectory}/conf \
|
|
bpsensei.pxar:${GauntRouterSSHFSMountDirectory}/usr/local/bpsensei \
|
|
--backup-id GauntRouter01 \
|
|
--ns Hosts \
|
|
--repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
|
# umount and remove directory
|
|
/usr/bin/umount --force --lazy --quiet ${GauntRouterSSHFSMountDirectory} && \
|
|
/usr/bin/rmdir ${GauntRouterSSHFSMountDirectory}
|
|
|
|
# Backup TheGauntsRouter
|
|
DNSName="172.21.0.6"
|
|
TheGauntsRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
|
/usr/bin/mkdir ${TheGauntsRouterSSHFSMountDirectory} && \
|
|
/usr/bin/echo ${TheGauntsRouterEncryptedRootPassword} | \
|
|
/usr/bin/clevis decrypt | \
|
|
/usr/bin/sshfs -o password_stdin -o ro \
|
|
root@${DNSName}:/ ${TheGauntsRouterSSHFSMountDirectory} && \
|
|
/usr/bin/proxmox-backup-client backup \
|
|
conf.pxar:${TheGauntsRouterSSHFSMountDirectory}/conf \
|
|
bpsensei.pxar:${TheGauntsRouterSSHFSMountDirectory}/usr/local/bpsensei \
|
|
--backup-id TheGauntsRouter \
|
|
--ns Hosts \
|
|
--repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
|
# umount and remove directory
|
|
/usr/bin/umount --force --lazy --quiet ${TheGauntsRouterSSHFSMountDirectory} && \
|
|
/usr/bin/rmdir ${TheGauntsRouterSSHFSMountDirectory}
|
|
|
|
# Backup GauntNAS
|
|
DNSName="gauntnas.home.johnhgaunt.com"
|
|
GauntNASSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
|
/usr/bin/mkdir ${GauntNASSSHFSMountDirectory} && \
|
|
/usr/bin/echo ${GauntNASEncryptedRootPassword} | \
|
|
/usr/bin/clevis decrypt | \
|
|
/usr/bin/sshfs -o password_stdin -o ro \
|
|
root@${DNSName}:/ ${GauntNASSSHFSMountDirectory} && \
|
|
/usr/bin/proxmox-backup-client backup \
|
|
data.pxar:${GauntNASSSHFSMountDirectory}/data \
|
|
etc.pxar:${GauntNASSSHFSMountDirectory}/etc \
|
|
root.pxar:${GauntNASSSHFSMountDirectory}/root \
|
|
--backup-id GauntNAS \
|
|
--ns Hosts \
|
|
--repository GauntPBS01-Helper@pbs@gauntpbs01.home.johnhgaunt.com:8007:GauntPBS01-Local
|
|
# umount and remove directory
|
|
/usr/bin/umount --force --lazy --quiet ${GauntNASSSHFSMountDirectory} && \
|
|
/usr/bin/rmdir ${GauntNASSSHFSMountDirectory} |