Last active
June 11, 2022 17:54
-
-
Save kylegarcher/449167b45c81eb3ddbc6b01ded3b5efc to your computer and use it in GitHub Desktop.
Warn if rclone remote destination becomes too large
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/sh | |
CLOUDDEST="<remote destination>:/" | |
RCLONE_WARNING_SIZE_GB=500 # Replace as desired | |
RCLONE_ALERT_SIZE_GB=1000 # Replace as desired | |
echo "Checking Rclone remote size ($CLOUDDEST)" | |
rclone_size="$(rclone size --json $CLOUDDEST)" | |
rclone_size_bytes="$(echo $rclone_size | jq '.bytes')" | |
rclone_size_gbytes="$((rclone_size_bytes / 1024**3))" | |
echo "rclone size: $rclone_size_gbytes GB" | |
rclone_warning_size_message="WARNING: rclone size $rclone_size_gbytes GB > $RCLONE_WARNING_SIZE_GB" | |
rclone_alert_size_message="ALERT: rclone size $rclne_size_gbytes GB > $RCLONE_ALERT_SIZE_GB GB" | |
if [ $rclone_size_gbytes -ge $RCLONE_WARNING_SIZE_GB ]; then | |
echo "$rclone_warning_size_message" | |
# Place your warning command of choice here | |
# For example, if using Unraid: | |
# notify -i warning -s "rclone size" -d "$rclone_warning_size_message" | |
elif [ $rclone_size_gbytes -ge $RCLONE_ALERT_SIZE_GB ]; then | |
echo "$rclone_alert_size_message" | |
# Place your alert command of choice here | |
# For example, if using Unraid: | |
# notify -i alert -s "rclone size" -d "$rclone_alert_size_message" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment