For “Off-Site” backup I have a Proxmox Backup Server in my garden house / tool shed.
This server is powered off when not in use (controlled by Home Assistant), which again gives a continuous stream of error messages in the log about the missing datastore:
Sep 19 10:58:38 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (Connection timed out)
Sep 19 10:58:44 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 10:58:55 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 10:59:05 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
To solve this I first used a solution where I enabled/disabled the datastore from Home Assistant, but then came upon this article where a script is used on the Proxmox host.
I got the script to disable the datastore, but the script did not work for the enabling part.
I then followed the advice in the comment by “gurubert“, and installed jq (apt install jq). Then I changed the function that checks if the datastore is enabled:
# Function to check if a datastore is enabled
is_datastore_enabled() {
local datastore_id=$1
disable_status=$(/usr/bin/pvesh get /storage/$datastore_id --output-format json-pretty | jq '.disable')
if [ "$disable_status" = 1 ]; then
return 1 # Datastore is disabled
else
return 0 # Datastore is enabled
fi
}
I powered off the Backup-server after setting up a cron-job to run the script every 2 minutes (as described in the article). The log shows:
Sep 19 11:52:01 pve CRON[3341957]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Sep 19 11:52:01 pve CRON[3341960]: (root) CMD (/usr/local/sbin/pbs_datastore.sh > /dev/null 2>&1)
Sep 19 11:52:02 pve CRON[3341957]: pam_unix(cron:session): session closed for user root
Sep 19 11:53:19 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (Connection timed out)
Sep 19 11:53:28 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (Connection timed out)
Sep 19 11:53:35 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 11:53:45 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 11:53:55 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 11:54:01 pve CRON[3345020]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Sep 19 <strong>11:54:01</strong> pve CRON[3345021]: (root) CMD (/usr/local/sbin/pbs_datastore.sh > /dev/null 2>&1)
Sep 19 11:54:05 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 11:54:14 pve pvestatd[1477]: pbs-remote: error fetching datastores - 500 Can't connect to 192.168.86.206:8007 (No route to host)
Sep 19 <strong>11:54:18</strong> pve CRON[3345020]: pam_unix(cron:session): session closed for user root
Sep 19 11:56:01 pve CRON[3347937]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Sep 19 11:56:01 pve CRON[3347938]: (root) CMD (/usr/local/sbin/pbs_datastore.sh > /dev/null 2>&1)
Sep 19 11:56:17 pve CRON[3347937]: pam_unix(cron:session): session closed for user root
We can clearly see that there are no more “error fetching datastores”-messages in the log after the interval 11:54:01 (start cron-job – pinging for pbs-server) and 11:54:18 (end of cron-job).
In the GUI we see that the datastore has been disabled.