Renamed script and moved mkdir for each host to own command and doesn't have to be successful
This commit is contained in:
70
backupHosts.sh
Normal file
70
backupHosts.sh
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/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 -v ${GauntRouterSSHFSMountDirectory}
|
||||
/usr/bin/echo ${GauntRouter01EncryptedRootPassword} | \
|
||||
/usr/bin/clevis decrypt | \
|
||||
/usr/bin/sshfs -o password_stdin -o ro -o StrictHostKeyChecking=no \
|
||||
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 -v --force --lazy --quiet ${GauntRouterSSHFSMountDirectory} && \
|
||||
/usr/bin/rmdir -v ${GauntRouterSSHFSMountDirectory}
|
||||
|
||||
# Backup TheGauntsRouter
|
||||
DNSName="10.1.4.2"
|
||||
TheGauntsRouterSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
||||
/usr/bin/mkdir -v ${TheGauntsRouterSSHFSMountDirectory}
|
||||
/usr/bin/echo ${TheGauntsRouterEncryptedRootPassword} | \
|
||||
/usr/bin/clevis decrypt | \
|
||||
/usr/bin/sshfs -o password_stdin -o ro -o StrictHostKeyChecking=no \
|
||||
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 -v --force --lazy --quiet ${TheGauntsRouterSSHFSMountDirectory} && \
|
||||
/usr/bin/rmdir -v ${TheGauntsRouterSSHFSMountDirectory}
|
||||
|
||||
# Backup GauntNAS
|
||||
DNSName="gauntnas.home.johnhgaunt.com"
|
||||
GauntNASSSHFSMountDirectory="${SSHFSMountDirectory}/${DNSName}"
|
||||
/usr/bin/mkdir -v ${GauntNASSSHFSMountDirectory}
|
||||
/usr/bin/echo ${GauntNASEncryptedRootPassword} | \
|
||||
/usr/bin/clevis decrypt | \
|
||||
/usr/bin/sshfs -o password_stdin -o ro -o StrictHostKeyChecking=no \
|
||||
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 -v --force --lazy --quiet ${GauntNASSSHFSMountDirectory} && \
|
||||
/usr/bin/rmdir -v ${GauntNASSSHFSMountDirectory}
|
||||
Reference in New Issue
Block a user