Last active
February 14, 2024 01:20
-
-
Save willjasen/f043834c9bbdde18be24e5fd28ba585a to your computer and use it in GitHub Desktop.
toggles replication jobs on a host (enable/disable)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Moved to https://github.com/willjasen/proxmox-scripts/blob/main/bulk-toggle-proxmox-replication-jobs.sh | |
# Output may show "trying to acquire cfs lock 'file-replication_cfg' ..." at some point but script should still finish | |
# EDIT: true to disable jobs, false to enable jobs | |
DISABLE=true; | |
# Make sure jq is installed | |
apt install jq -y; | |
# Get all job IDs | |
jobIDs=$(pvesr list | awk '{print $1}' | grep -Eo '[1-9][0-9]{2,8}-[0-9]{1,9}'); | |
# toggle the jobs if they need to be | |
for jobID in $jobIDs; do | |
if $DISABLE; then | |
pvesr read $jobID | jq --exit-status '.disable' >/dev/null; | |
if test $? -eq 1; then | |
echo -e "Disabling replication job $jobID"; | |
pvesr update $jobID --disable $DISABLE; | |
else | |
echo -e "Replication job $jobID is already disabled"; | |
fi | |
else | |
pvesr read $jobID | jq --exit-status '.disable' >/dev/null; | |
if test $? -eq 0; then | |
echo -e "Enabling replication job $jobID"; | |
pvesr update $jobID --disable $DISABLE; | |
else | |
echo -e "Replication job $jobID is already enabled"; | |
fi | |
fi | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment