This commit is contained in:
Lee
2025-05-10 04:19:26 +01:00
parent 90c539a5fe
commit 7c66fb7964

View File

@ -61,10 +61,17 @@ validate_config() {
exit 1
fi
# Check if backup path exists and is accessible
if [ ! -d "${CONFIG[BACKUP_PATH]}" ]; then
echo "Error: Backup path does not exist: ${CONFIG[BACKUP_PATH]}"
exit 1
fi
# Check if we have read permissions
if [ ! -r "${CONFIG[BACKUP_PATH]}" ]; then
echo "Error: No read permission for backup path: ${CONFIG[BACKUP_PATH]}"
exit 1
fi
}
parse_arguments() {
@ -249,8 +256,15 @@ main() {
# Run backup
log "Running backup..."
log "Command: restic -r ${CONFIG[RESTIC_REPOSITORY]} backup ${CONFIG[BACKUP_PATH]}"
# Check if restic command exists and is executable
if ! command -v restic >/dev/null 2>&1; then
log "Error: restic command not found"
backup_exit_code=1
else
# Run the backup command and capture both stdout and stderr
if ! restic -r "${CONFIG[RESTIC_REPOSITORY]}" backup "${CONFIG[BACKUP_PATH]}" >> "$BACKUP_LOG" 2>&1; then
log "Backup failed with exit code $?"
log "Backup failed. Check the log file for details: $BACKUP_LOG"
backup_exit_code=1
else
backup_exit_code=0
@ -258,6 +272,7 @@ main() {
# Add a small delay to ensure the snapshot is registered
sleep 2
fi
fi
# Get snapshot information
log "Getting snapshot information..."