Add configurable disk usage threshold setting
Disk usage threshold (default 95%) can now be controlled from Settings. Set to 0 to disable the check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -78,11 +78,14 @@ _backup_target_impl() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# 4.5. Check remote disk space (fail if >= 95%)
|
# 4.5. Check remote disk space
|
||||||
check_remote_disk_space 95 || {
|
local threshold="${DISK_USAGE_THRESHOLD:-$DEFAULT_DISK_USAGE_THRESHOLD}"
|
||||||
log_error "Remote '$remote_name' has insufficient disk space"
|
if [[ "$threshold" -gt 0 ]]; then
|
||||||
return 1
|
check_remote_disk_space "$threshold" || {
|
||||||
}
|
log_error "Remote '$remote_name' has insufficient disk space"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
local start_time; start_time=$(date +%s)
|
local start_time; start_time=$(date +%s)
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ load_config() {
|
|||||||
SSH_TIMEOUT="${SSH_TIMEOUT:-$DEFAULT_SSH_TIMEOUT}"
|
SSH_TIMEOUT="${SSH_TIMEOUT:-$DEFAULT_SSH_TIMEOUT}"
|
||||||
SSH_RETRIES="${SSH_RETRIES:-$DEFAULT_SSH_RETRIES}"
|
SSH_RETRIES="${SSH_RETRIES:-$DEFAULT_SSH_RETRIES}"
|
||||||
RSYNC_EXTRA_OPTS="${RSYNC_EXTRA_OPTS:-}"
|
RSYNC_EXTRA_OPTS="${RSYNC_EXTRA_OPTS:-}"
|
||||||
|
DISK_USAGE_THRESHOLD="${DISK_USAGE_THRESHOLD:-$DEFAULT_DISK_USAGE_THRESHOLD}"
|
||||||
|
|
||||||
# WORK_DIR can be overridden in config; re-export if changed
|
# WORK_DIR can be overridden in config; re-export if changed
|
||||||
export WORK_DIR
|
export WORK_DIR
|
||||||
@@ -64,7 +65,7 @@ load_config() {
|
|||||||
export BACKUP_MODE BWLIMIT RETENTION_COUNT
|
export BACKUP_MODE BWLIMIT RETENTION_COUNT
|
||||||
export LOG_LEVEL LOG_RETAIN NOTIFY_EMAIL NOTIFY_ON
|
export LOG_LEVEL LOG_RETAIN NOTIFY_EMAIL NOTIFY_ON
|
||||||
export SMTP_HOST SMTP_PORT SMTP_USER SMTP_FROM SMTP_SECURITY
|
export SMTP_HOST SMTP_PORT SMTP_USER SMTP_FROM SMTP_SECURITY
|
||||||
export SSH_TIMEOUT SSH_RETRIES RSYNC_EXTRA_OPTS
|
export SSH_TIMEOUT SSH_RETRIES RSYNC_EXTRA_OPTS DISK_USAGE_THRESHOLD
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_config() {
|
validate_config() {
|
||||||
|
|||||||
@@ -48,3 +48,4 @@ readonly DEFAULT_REMOTE_TYPE="ssh"
|
|||||||
readonly DEFAULT_S3_REGION="us-east-1"
|
readonly DEFAULT_S3_REGION="us-east-1"
|
||||||
readonly DEFAULT_SMTP_PORT=587
|
readonly DEFAULT_SMTP_PORT=587
|
||||||
readonly DEFAULT_SMTP_SECURITY="tls"
|
readonly DEFAULT_SMTP_SECURITY="tls"
|
||||||
|
readonly DEFAULT_DISK_USAGE_THRESHOLD=95
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ class AppSettings:
|
|||||||
ssh_timeout: str = "30"
|
ssh_timeout: str = "30"
|
||||||
ssh_retries: str = "3"
|
ssh_retries: str = "3"
|
||||||
rsync_extra_opts: str = ""
|
rsync_extra_opts: str = ""
|
||||||
|
disk_usage_threshold: str = "95"
|
||||||
work_dir: str = "/usr/local/gniza/workdir"
|
work_dir: str = "/usr/local/gniza/workdir"
|
||||||
web_port: str = "2323"
|
web_port: str = "2323"
|
||||||
web_host: str = "0.0.0.0"
|
web_host: str = "0.0.0.0"
|
||||||
@@ -229,6 +230,7 @@ class AppSettings:
|
|||||||
ssh_timeout=data.get("SSH_TIMEOUT", "30"),
|
ssh_timeout=data.get("SSH_TIMEOUT", "30"),
|
||||||
ssh_retries=data.get("SSH_RETRIES", "3"),
|
ssh_retries=data.get("SSH_RETRIES", "3"),
|
||||||
rsync_extra_opts=data.get("RSYNC_EXTRA_OPTS", ""),
|
rsync_extra_opts=data.get("RSYNC_EXTRA_OPTS", ""),
|
||||||
|
disk_usage_threshold=data.get("DISK_USAGE_THRESHOLD", "95"),
|
||||||
work_dir=data.get("WORK_DIR", "/usr/local/gniza/workdir"),
|
work_dir=data.get("WORK_DIR", "/usr/local/gniza/workdir"),
|
||||||
web_port=data.get("WEB_PORT", "8080"),
|
web_port=data.get("WEB_PORT", "8080"),
|
||||||
web_host=data.get("WEB_HOST", "0.0.0.0"),
|
web_host=data.get("WEB_HOST", "0.0.0.0"),
|
||||||
@@ -253,6 +255,7 @@ class AppSettings:
|
|||||||
"SSH_TIMEOUT": self.ssh_timeout,
|
"SSH_TIMEOUT": self.ssh_timeout,
|
||||||
"SSH_RETRIES": self.ssh_retries,
|
"SSH_RETRIES": self.ssh_retries,
|
||||||
"RSYNC_EXTRA_OPTS": self.rsync_extra_opts,
|
"RSYNC_EXTRA_OPTS": self.rsync_extra_opts,
|
||||||
|
"DISK_USAGE_THRESHOLD": self.disk_usage_threshold,
|
||||||
"WORK_DIR": self.work_dir,
|
"WORK_DIR": self.work_dir,
|
||||||
"WEB_PORT": self.web_port,
|
"WEB_PORT": self.web_port,
|
||||||
"WEB_HOST": self.web_host,
|
"WEB_HOST": self.web_host,
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class SettingsScreen(Screen):
|
|||||||
yield Input(value=settings.retention_count, id="set-retention")
|
yield Input(value=settings.retention_count, id="set-retention")
|
||||||
yield Static("Default Bandwidth Limit (KB/s, 0=unlimited):")
|
yield Static("Default Bandwidth Limit (KB/s, 0=unlimited):")
|
||||||
yield Input(value=settings.bwlimit, id="set-bwlimit")
|
yield Input(value=settings.bwlimit, id="set-bwlimit")
|
||||||
|
yield Static("Disk Usage Threshold (%, 0=disable):")
|
||||||
|
yield Input(value=settings.disk_usage_threshold, id="set-diskthreshold")
|
||||||
yield Static("Notification Email:")
|
yield Static("Notification Email:")
|
||||||
yield Input(value=settings.notify_email, id="set-email")
|
yield Input(value=settings.notify_email, id="set-email")
|
||||||
yield Static("Notify On:")
|
yield Static("Notify On:")
|
||||||
@@ -100,6 +102,7 @@ class SettingsScreen(Screen):
|
|||||||
ssh_timeout=self.query_one("#set-sshtimeout", Input).value.strip() or "30",
|
ssh_timeout=self.query_one("#set-sshtimeout", Input).value.strip() or "30",
|
||||||
ssh_retries=self.query_one("#set-sshretries", Input).value.strip() or "3",
|
ssh_retries=self.query_one("#set-sshretries", Input).value.strip() or "3",
|
||||||
rsync_extra_opts=self.query_one("#set-rsyncopts", Input).value.strip(),
|
rsync_extra_opts=self.query_one("#set-rsyncopts", Input).value.strip(),
|
||||||
|
disk_usage_threshold=self.query_one("#set-diskthreshold", Input).value.strip() or "95",
|
||||||
work_dir=self.query_one("#set-workdir", Input).value.strip() or "/usr/local/gniza/workdir",
|
work_dir=self.query_one("#set-workdir", Input).value.strip() or "/usr/local/gniza/workdir",
|
||||||
web_port=self.query_one("#set-web-port", Input).value.strip() or "8080",
|
web_port=self.query_one("#set-web-port", Input).value.strip() or "8080",
|
||||||
web_host=self.query_one("#set-web-host", Input).value.strip() or "0.0.0.0",
|
web_host=self.query_one("#set-web-host", Input).value.strip() or "0.0.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user