Friday, November 15, 2024

macos – Why am I getting this Rsync error on my MacBook?

I made a backup from an NTFS formatted USB flash drive to transfer files to a MacBook. For this purpose I created a simple bash script (I upgraded bash to 5.2 with homebrew):

#!/bin/bash

declare -A BACKUP_INFOS
BACKUP_INFOS=(
[/Users/<myuser>/Documents]="/Volumes/CORSAIR128/argomentare
/Volumes/CORSAIR128/articoli /Volumes/CORSAIR128/bibliografie ... /Volumes/CORSAIR128/xindy"
)

for dest_dir in "${!BACKUP_INFOS[@]}"
do
mkdir -p "$dest_dir"
src="${BACKUP_INFOS[$dest_dir]}"
rsync -avuz --delete --delete-after --progress $src "$dest_dir"
done

The file always worked until I upgraded my OS from Sonoma to Sequoia, but I can’t tell if there’s a connection.
Now the script doesn’t work anymore and I get this error:

rsync: [sender]readdir("/Volumes/CORSAIR128/argomentare"): Invalid arguments (22)
rsync: [sender]readdir("/Volumes/CORSAIR128/articoli"): Invalid arguments (22)
300 files
rsync: [sender] readlink_stat("/Volumes/CORSAIR128/articoli /Volumes/CORSAIR128/bibliografie/nagel.doc") failed: Bad file descriptor (9)
...

I don’t understand what this could depend on. If you need more information, please specify what is needed to understand better the nature of the problem.
Thanks

Update 1: I tried to set this:

#!/usr/bin/env bash
set -x

But the result is always the same one.

Update 2: I set bash to be my shell and not zsh. However I receive new, different errors, with the above script:

macbook.sh line 3: declare -A: invalid option
...
macbook.sh line 27: /Users/<myuser>/Documents: syntax error: operand expected (error token is "/Users/<myuser>/Documents")

Related Articles

Latest Articles