Update pbs-zfs-daily.sh

Now with Bashclub ZSYNC
This commit is contained in:
Chriz
2024-01-24 21:49:54 +01:00
committed by GitHub
parent de6a91c619
commit b1248c4a32

View File

@@ -3,18 +3,21 @@
#Requirements for Myiagi ultimate Backup
## Proxmox Source Host with only daily Autosnapshots, Proxmox Destination Host, Destination Public SSH Key on Source authorized-keys File, autostarting Proxmox Backupserver running on this PVE, zfs set com.sun:auto-snapshots=false on $ZFSTRGT, instaled checkzfs from https://github.com/bashclub/check-zfs-replication, check_mk Agent running on PVE
SOURCEHOST='192.168.0.241' # IP from Proxmox VE System to be backuped and replicated daily
SOURCEHOSTNAME='pve' #Hostname of Proxmox VE System to be backuped and replicated daily
ZFSKEEP='10' # How many Snapshots to be kept, suggested 10 Days
SOURCEHOST='192.168.1.20' # IP from Proxmox VE System to be backuped and replicated daily
SOURCEHOSTNAME='pve20' #Hostname of Proxmox VE System to be backuped and replicated daily
ZFSROOT='rpool/data' #First Dataset/Datastoresourcepath from Proxmox VE System to be backuped and replicated daily
ZFSTRGT='rpool/repl' #This pulling Machines Target ZFS Sourcepath
ZPOOLSRC=rpool #First Pool/Tank from Proxmox VE System to be backuped and replicated daily
ZPOOLDST=rpool #This pulling Machines Pool/Tank
ZPUSHTAG=bashclub:zsync
ZPUSHMINKEEP=3
ZPUSHKEEP=14
ZPUSHLABEL=zsync-30
ZPUSHFILTER="\"monthly|daily\"" #zpushlabel kommt automatisch mit
PBSHOST='192.168.0.171' #IP from your Proxmox Backupserver
BACKUPSTORE=backup241 #Datastorename configured in your Proxmox VE System to be backuped and replicated daily
PBSHOST='192.168.1.16' #IP from your Proxmox Backupserver
BACKUPSTORE=backup #Datastorename configured in your Proxmox VE System to be backuped and replicated daily
BACKUPSTOREPBS=backup #Datastorename configured in your Proxmox Backup Server
BACKUPEXCLUDE='999' #Machines to be excluded from Proxmox Backup
PRUNEJOB=$(ssh $PBSHOST proxmox-backup-manager prune-job list --output-format json-pretty | grep -m 1 "id" | cut -d'"' -f4)
@@ -24,15 +27,19 @@ SCRIPTPATH=/usr/bin #Location of bashclub-zfs Tool - https://raw.githubuserconte
MAINTDAY=0
SOURCEALL=$(ssh -p$SSHPORT root@$SOURCEHOST 'for src in $(zfs list -H -o name |grep '"$ZFSROOT"'/|grep -v alt|grep -v state|grep -v disk-9); do echo ${src##*/}; done') #determines Source Datasets without 'alt, state and disk-9' in Name - Those are typlically not replicated
echo ''
echo Pulling Replicas from $SOURCEHOST following Datasets/ZVOLS $SOURCEALL
echo ''
for DATA in $SOURCEALL
do
$SCRIPTPATH/bashclub-zfs -p $SSHPORT -k $ZFSKEEP -v $SOURCEHOST:$ZFSROOT/$DATA $ZFSTRGT #for debugging add an echo at the Beginning of this line
done
###
# ssh root@$SOURCEHOST zfs set $ZPUSHTAG=subvols $ZFSROOT
# Schleife für Excludes
echo "target=rpool/repl" > /etc/bashclub/$SOURCEHOST.conf
echo "source=root@$SOURCEHOST" >> /etc/bashclub/$SOURCEHOST.conf
echo "sshport=$SSHPORT" >> /etc/bashclub/$SOURCEHOST.conf
echo "tag=$ZPUSHTAG" >> /etc/bashclub/$SOURCEHOST.conf
echo "snapshot_filter=$ZPUSHFILTER" >> /etc/bashclub/$SOURCEHOST.conf
echo "min_keep=$ZPUSHMINKEEP" >> /etc/bashclub/$SOURCEHOST.conf
echo "zfs_auto_snapshot_keep=$ZPUSHKEEP" >> /etc/bashclub/$SOURCEHOST.conf
echo "zfs_auto_snapshot_label=$ZPUSHLABEL" >> /etc/bashclub/$SOURCEHOST.conf
/usr/bin/bashclub-zsync -d -c /etc/bashclub/$SOURCEHOST.conf
# So one Day has 1440 Minutes, so we go condition Yellow on 1500
/usr/local/bin/checkzfs --source $SOURCEHOST --replicafilter $ZFSTRGT/ --filter $ZFSROOT/ --threshold 1500,2000 --output checkmk --prefix pullrepl > /tmp/cmk_tmp.out && ( echo "<<<local>>>" ; cat /tmp/cmk_tmp.out ) > /tmp/90000_checkzfs