Skip to content

Commit 429fccd

Browse files
committed
Improve rclone config handling and add detailed error logging
1 parent 0929313 commit 429fccd

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

scripts/backup-functions.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fi
1010

1111
# Global variable for the rclone remote name
1212
REMOTE_NAME=""
13-
RCLONE_CONFIG_PATH="~/.config/rclone/rclone.conf"
13+
RCLONE_CONFIG_PATH="/root/.config/rclone/rclone.conf"
1414

1515
# Logging function
1616
log() {
@@ -181,10 +181,20 @@ setup_rclone() {
181181
log "INFO" "Using first rclone remote from config: '$REMOTE_NAME'"
182182
else
183183
log "ERROR" "No remote found in rclone configuration and RCLONE_REMOTE_NAME not specified."
184+
log "ERROR" "Checking rclone config file contents..."
185+
if [ -f "$RCLONE_CONFIG_PATH" ]; then
186+
log "INFO" "Config file exists at: $RCLONE_CONFIG_PATH"
187+
log "INFO" "Config file contents:"
188+
cat "$RCLONE_CONFIG_PATH" | head -10
189+
else
190+
log "ERROR" "Config file not found at: $RCLONE_CONFIG_PATH"
191+
fi
184192
return 1
185193
fi
186194
fi
187195

196+
log "INFO" "Final REMOTE_NAME set to: '$REMOTE_NAME'"
197+
188198
if [[ -z "$REMOTE_NAME" ]] || ! [[ "$REMOTE_NAME" =~ ^[a-zA-Z0-9_.-]+$ ]]; then
189199
log "ERROR" "Invalid remote name: '$REMOTE_NAME'."
190200
return 1
@@ -211,6 +221,13 @@ compress_and_upload() {
211221
local remote_filename="$3"
212222
local temp_compressed_file
213223

224+
# Check if REMOTE_NAME is set
225+
if [[ -z "$REMOTE_NAME" ]]; then
226+
log "ERROR" "REMOTE_NAME is not set. Cannot upload file."
227+
log "ERROR" "Please ensure rclone is properly configured."
228+
return 1
229+
fi
230+
214231
if [[ ! -s "$source_file" ]]; then
215232
log "WARN" "Source file $source_file does not exist or is empty. Skipping upload."
216233
return 0

0 commit comments

Comments
 (0)