aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Scholten2025-10-22 16:44:53 +1000
committerSam Scholten2025-10-22 16:44:53 +1000
commit61ca95ae5929928ebfa50b8d99b18cf21c3e2ca7 (patch)
tree0124c23545f21aee35107efb42a7827bb93e3179
parent4352c0aedd3236b805977da8fc910fb8f46a9e2d (diff)
downloaddrestic-61ca95ae5929928ebfa50b8d99b18cf21c3e2ca7.tar.gz
drestic-61ca95ae5929928ebfa50b8d99b18cf21c3e2ca7.zip
Fix: Replace unsupported restic flags for 0.18.1 compatibilityv1.2
- Replace --lock-retry-after and --lock-stale-timeout with --retry-lock - Fix shell script quoting issues (SC2086, SC2046) - All tests passing: local, remote, lint, format
-rw-r--r--CHANGELOG.md8
-rw-r--r--VERSION2
-rwxr-xr-xrestic_backup.sh12
-rwxr-xr-xrestic_check.sh3
-rwxr-xr-xupdate.sh46
-rwxr-xr-xupdate_gotify.sh92
6 files changed, 83 insertions, 80 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20fa842..0533522 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+drestic (1.2.3) stable; urgency=medium
+
+ * Fixed: Replaced unsupported --lock-retry-after and --lock-stale-timeout flags with --retry-lock for restic 0.18.1 compatibility
+ * Fixed: Shell script quoting issues found by shellcheck (SC2086, SC2046)
+ * Improved: All tests passing (local, remote, lint, format)
+
+ -- Sam <samsci@posteo.com> Wed, 22 Oct 2025 16:27:00 +1000
+
drestic (1.2.0) stable; urgency=medium
* Added automated update script for seamless upgrades
diff --git a/VERSION b/VERSION
index 867e524..e2cac26 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.2.0 \ No newline at end of file
+1.2.3 \ No newline at end of file
diff --git a/restic_backup.sh b/restic_backup.sh
index cc749e6..b68d299 100755
--- a/restic_backup.sh
+++ b/restic_backup.sh
@@ -37,28 +37,25 @@ restic backup \
--exclude-file "${CONFIG_DIR}/excludes" \
--password-file "${RESTIC_PASSWORD_FILE}" \
--option rclone.timeout=20m \
- --lock-retry-after 5m \
- --lock-stale-timeout 24h \
+ --retry-lock 5m \
--tag daily || {
echo "Error: Restic backup failed." >&2
notify "Restic Backup ($(whoami)@$(hostname))" "Backup phase failed!" 8
exit 1
}
-
# Prune old snapshots - only on specific hours to avoid conflicts
HOUR=$(date +%H)
# Only prune between 2-4 AM to reduce multi-device conflicts
-if [ $HOUR -ge 2 ] && [ $HOUR -lt 4 ]; then
+if [ "$HOUR" -ge 2 ] && [ "$HOUR" -lt 4 ]; then
# Add random delay to stagger multiple devices
- sleep $(shuf -i 0-1800 -n 1) # 0-30 minutes random delay
+ sleep "$(shuf -i 0-1800 -n 1)" # 0-30 minutes random delay
echo "Applying Restic retention policy and pruning old snapshots..."
restic forget \
--repo "${RESTIC_REPOSITORY}" \
--password-file "${RESTIC_PASSWORD_FILE}" \
--option rclone.timeout=20m \
- --lock-retry-after 5m \
- --lock-stale-timeout 24h \
+ --retry-lock 5m \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
@@ -72,5 +69,4 @@ else
echo "Skipping prune - only running between 2-4 AM to avoid multi-device conflicts"
fi
-
echo "--- Restic Backup finished at $(date) ---"
diff --git a/restic_check.sh b/restic_check.sh
index c8271ea..278b2fe 100755
--- a/restic_check.sh
+++ b/restic_check.sh
@@ -34,8 +34,7 @@ restic check \
--password-file "${RESTIC_PASSWORD_FILE}" \
--read-data-subset 1% \
--no-cache \
- --lock-retry-after 5m \
- --lock-stale-timeout 24h \
+ --retry-lock 5m \
--verbose || {
echo "Error: Restic check failed." >&2
notify "Restic Check ($(whoami)@$(hostname))" "Weekly integrity check failed!" 8
diff --git a/update.sh b/update.sh
index 6bc6de8..2b21a77 100755
--- a/update.sh
+++ b/update.sh
@@ -36,23 +36,23 @@ check_permissions() {
backup_configs() {
local install_type="$1"
local backup_dir
-
+
if [ "$install_type" = "system" ]; then
backup_dir="/etc/restic/backup-$(date +%Y%m%d-%H%M%S)"
sudo mkdir -p "$backup_dir"
- else
+ else
backup_dir="$HOME/.config/restic/backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
fi
-
+
log "Backing up configuration to $backup_dir"
-
+
if [ "$install_type" = "system" ]; then
sudo cp -r /etc/restic/* "$backup_dir/" 2>/dev/null || true
- else
+ else
cp -r "$HOME/.config/restic"/* "$backup_dir/" 2>/dev/null || true
fi
-
+
echo "$backup_dir"
}
@@ -60,7 +60,7 @@ backup_configs() {
update_scripts() {
local install_type="$1"
local install_dir
-
+
if [ "$install_type" = "system" ]; then
install_dir="/usr/local/bin"
log "Updating scripts in $install_dir"
@@ -83,7 +83,7 @@ update_scripts() {
update_services() {
local install_type="$1"
local systemd_dir
-
+
if [ "$install_type" = "system" ]; then
systemd_dir="/etc/systemd/system"
log "Updating systemd services in $systemd_dir"
@@ -104,13 +104,13 @@ update_services() {
update_bandwidth() {
local install_type="$1"
local env_file
-
+
if [ "$install_type" = "system" ]; then
env_file="/root/.restic_env"
else
env_file="$HOME/.config/restic/env"
fi
-
+
# Check if file exists and has old bandwidth setting
if [ -f "$env_file" ] && grep -q "RCLONE_BWLIMIT=1M" "$env_file"; then
log "Updating rclone bandwidth limit from 1M to 2M"
@@ -125,7 +125,7 @@ update_bandwidth() {
# Restart services
restart_services() {
local install_type="$1"
-
+
log "Restarting systemd timers"
if [ "$install_type" = "system" ]; then
sudo systemctl restart restic-backup.timer restic-check.timer
@@ -141,39 +141,39 @@ restart_services() {
# Main update logic
main() {
log "Starting drestic update process"
-
+
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
-
+
# Check we're in a git repo
- if ! git rev-parse --git-dir > /dev/null 2>&1; then
+ if ! git rev-parse --git-dir >/dev/null 2>&1; then
error "Not in a git repository. Please run from drestic directory."
fi
-
+
# Detect installation type
install_type=$(detect_installation)
log "Detected $install_type installation"
-
+
# Check permissions
check_permissions "$install_type"
-
+
# Backup configs
backup_dir=$(backup_configs "$install_type")
log "Configuration backed up to: $backup_dir"
-
+
# Update scripts
update_scripts "$install_type"
-
+
# Update services
update_services "$install_type"
-
+
# Update bandwidth (optional)
update_bandwidth "$install_type"
-
+
# Restart services
restart_services "$install_type"
-
+
log "Update completed successfully!"
echo ""
echo "Key improvements in this update:"
@@ -186,4 +186,4 @@ main() {
}
# Run main function
-main "$@" \ No newline at end of file
+main "$@"
diff --git a/update_gotify.sh b/update_gotify.sh
index 5305752..0695507 100755
--- a/update_gotify.sh
+++ b/update_gotify.sh
@@ -4,8 +4,8 @@ set -euo pipefail
ENV_FILE="$1"
if [ ! -f "$ENV_FILE" ]; then
- echo "Error: Environment file not found: $ENV_FILE"
- exit 1
+ echo "Error: Environment file not found: $ENV_FILE"
+ exit 1
fi
echo "Current Gotify configuration:"
@@ -14,58 +14,58 @@ echo
read -rp "Enter new Gotify URL (no trailing slash, e.g. https://gotify.example.com): " GOTIFY_URL
if [ -n "$GOTIFY_URL" ]; then
- # Validate URL format
- if [[ ! "$GOTIFY_URL" =~ ^https?:// ]]; then
- echo "Error: Invalid URL format (must start with http:// or https://)"
- exit 1
- fi
-
- # Test URL reachability
- echo "Testing Gotify server connectivity..."
- if ! curl -s --connect-timeout 10 "$GOTIFY_URL/health" >/dev/null 2>&1; then
- echo "Warning: Cannot reach Gotify server at $GOTIFY_URL"
- echo "This might be due to network issues or incorrect URL."
- read -rp "Continue anyway? [y/N]: " continue_anyway
- if [[ ! "$continue_anyway" =~ ^[Yy]$ ]]; then
- echo "Aborted."
- exit 1
- fi
- else
- echo "✓ Gotify server is reachable"
- fi
-
- read -rp "Enter new Gotify token: " GOTIFY_TOKEN
-
- # Test token if both URL and token are provided
- if [ -n "$GOTIFY_TOKEN" ]; then
- echo "Testing Gotify token..."
- if curl -sS "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" \
- -F "title=DRestic Config Test ($(whoami)@$(hostname))" \
- -F "message=Testing Gotify configuration from $(whoami)@$(hostname) - you can ignore this message" \
- -F "priority=1" >/dev/null 2>&1; then
- echo "✓ Test notification sent successfully!"
- else
- echo "Warning: Failed to send test notification. Please verify your token."
- read -rp "Continue anyway? [y/N]: " continue_anyway
- if [[ ! "$continue_anyway" =~ ^[Yy]$ ]]; then
- echo "Aborted."
- exit 1
- fi
- fi
- fi
+ # Validate URL format
+ if [[ ! "$GOTIFY_URL" =~ ^https?:// ]]; then
+ echo "Error: Invalid URL format (must start with http:// or https://)"
+ exit 1
+ fi
+
+ # Test URL reachability
+ echo "Testing Gotify server connectivity..."
+ if ! curl -s --connect-timeout 10 "$GOTIFY_URL/health" >/dev/null 2>&1; then
+ echo "Warning: Cannot reach Gotify server at $GOTIFY_URL"
+ echo "This might be due to network issues or incorrect URL."
+ read -rp "Continue anyway? [y/N]: " continue_anyway
+ if [[ ! "$continue_anyway" =~ ^[Yy]$ ]]; then
+ echo "Aborted."
+ exit 1
+ fi
+ else
+ echo "✓ Gotify server is reachable"
+ fi
+
+ read -rp "Enter new Gotify token: " GOTIFY_TOKEN
+
+ # Test token if both URL and token are provided
+ if [ -n "$GOTIFY_TOKEN" ]; then
+ echo "Testing Gotify token..."
+ if curl -sS "$GOTIFY_URL/message?token=$GOTIFY_TOKEN" \
+ -F "title=DRestic Config Test ($(whoami)@$(hostname))" \
+ -F "message=Testing Gotify configuration from $(whoami)@$(hostname) - you can ignore this message" \
+ -F "priority=1" >/dev/null 2>&1; then
+ echo "✓ Test notification sent successfully!"
+ else
+ echo "Warning: Failed to send test notification. Please verify your token."
+ read -rp "Continue anyway? [y/N]: " continue_anyway
+ if [[ ! "$continue_anyway" =~ ^[Yy]$ ]]; then
+ echo "Aborted."
+ exit 1
+ fi
+ fi
+ fi
else
- GOTIFY_TOKEN=""
+ GOTIFY_TOKEN=""
fi
# Update or add Gotify settings
sed -i '/^GOTIFY_URL=/d' "$ENV_FILE"
sed -i '/^GOTIFY_TOKEN=/d' "$ENV_FILE"
-echo "GOTIFY_URL=\"$GOTIFY_URL\"" >> "$ENV_FILE"
-echo "GOTIFY_TOKEN=\"$GOTIFY_TOKEN\"" >> "$ENV_FILE"
+echo "GOTIFY_URL=\"$GOTIFY_URL\"" >>"$ENV_FILE"
+echo "GOTIFY_TOKEN=\"$GOTIFY_TOKEN\"" >>"$ENV_FILE"
echo "✓ Gotify configuration updated!"
if [ -n "$GOTIFY_URL" ]; then
- echo "Test with: make test-remote-gotify"
+ echo "Test with: make test-remote-gotify"
else
- echo "Gotify notifications disabled"
+ echo "Gotify notifications disabled"
fi