3

In a bash script (Arch Linux) I have the following rsync command:

rsync –nvaAHX --inplace --delete-delay --exclude-from="/etc/$path1/exclude-list-$configName.txt" "$new_snap/" "$BACKUPDIR"

The rsync command fails with the following error:

rsync: --delete does not work without --recursive (-r) or --dirs (-d).

Of course, that message is misleading as "a" implies "r".

If I remove the option "--delete-delay" from the rsync command, I get this different error:

rsync: link_stat "/some/path/–aAHX" failed: No such file or directory (2)

The value shown at "/some/path" is the current working directory. If I change the current directory, that value in the error message changes as well. However, why the options "-aAHX" would be appended to any part of the path is confusing.

The computer is a fully updated Arch Linux system. I just rebooted it as well.

4.13.11-1-ARCH #1 SMP PREEMPT Thu Nov 2 10:25:56 CET 2017 x86_64 GNU/Linux

rsync program location:

# which rsync
/usr/bin/rsync

Here is the test script:

#!/bin/bash

path1=xyz
configName=root
new_snap=/.snapshots/1/snapshot
BACKUPDIR=/backup/$configName

echo "showing exclude file contents:"

cat "/etc/$path1/exclude-list-$configName.txt"

echo

echo rsync –nvaAHX --inplace --delete-delay --exclude-from="/etc/$path1/exclude-list-$configName.txt" "$new_snap/" "$BACKUPDIR"

rsync –nvaAHX --inplace --delete-delay --exclude-from="/etc/$path1/exclude-list-$configName.txt" "$new_snap/" "$BACKUPDIR"

Here are the contents of the file "/etc/$path/exclude-list-$configName.txt":

"dev/*"
"proc/*"
"sys/*"
"tmp/*"
"run/*"
"mnt/*"
"media/*"
"lost+found"
".trash*/*"
".Trash*/*"

Here is some testing without any script at all. I find it baffling.

# mkdir adir
# mkdir bdir
# touch adir/afile1
# touch adir/afile2

# ls -la adir/
total 0
drwxr-x--x 1 root root           24 Nov 12 02:21 .
drwxr-xr-x 1 user user         2080 Nov 12 02:28 ..
-rw-r----- 1 root root            0 Nov 12 02:21 afile1
-rw-r----- 1 root root            0 Nov 12 02:21 afile2
# ls -la bdir/
total 0
drwxr-x--x 1 root root            0 Nov 12 02:21 .
drwxr-xr-x 1 user user         2080 Nov 12 02:28 ..


# rsync -nva adir/ bdir
sending incremental file list
./
afile1
afile2

sent 93 bytes  received 25 bytes  236.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

# rsync -nva /home/user/adir/ /home/user/bdir
sending incremental file list
./
afile1
afile2

sent 93 bytes  received 25 bytes  236.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)


# rsync –nvaAHX --inplace --delete-delay --exclude-from=/root/exclude-list-root.txt /home/user/adir/ /home/user/bdir/
rsync: --delete does not work without --recursive (-r) or --dirs (-d).
rsync error: syntax or usage error (code 1) at main.c(1567) [client=3.1.2]
# rsync –nvaAHX --inplace --delete-delay /home/user/adir/ /home/user/bdir/
rsync: --delete does not work without --recursive (-r) or --dirs (-d).
rsync error: syntax or usage error (code 1) at main.c(1567) [client=3.1.2]
# rsync –nvaAHX --inplace /home/user/adir/ /home/user/bdir/
rsync: link_stat "/home/user/–nvaAHX" failed: No such file or directory (2)
skipping directory .
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
# rsync –nvaAHX /home/user/adir/ /home/user/bdir/
rsync: link_stat "/home/user/–nvaAHX" failed: No such file or directory (2)
skipping directory .
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
# rsync –nva /home/user/adir/ /home/user/bdir/
rsync: link_stat "/home/user/–nva" failed: No such file or directory (2)
skipping directory .
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
4
  • Why would you choose $path as a variable name? And how is it set?
    – jasonwryan
    Nov 12, 2017 at 6:34
  • @jasonwryan Looks like it's just a typo...all other references are to $path1.
    – B Layer
    Nov 12, 2017 at 7:25
  • Do you happen to have rsync as an alias or shell function in your working environment, or is it the name of a script that you have written?
    – Kusalananda
    Nov 12, 2017 at 7:27
  • UPDATED the question. Fixed the typo. I do not have rsync or anything close to that as an alias. I have not written any scripts with this name either.
    – MountainX
    Nov 12, 2017 at 7:53

2 Answers 2

7

That dash in front of n in –nvaHAX is not an ordinary dash but a slightly longer em-dash (or hyphen).

This may have happened if you're copy and pasting from a "smart" editor or word processor that replaces certain characters with the corresponding typographical character.

On my system, copying and pasting the first part of your command results in:

$ rsync –nva adir/ bdir/              
rsync: link_stat "/tmp_mfs/shell-ksh.D1Mq1Xht/\#342\#200\#223nva" failed: No such file or directory (2)
skipping directory .
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]

As you can see, my terminal displays the error message slightly differently from yours and shows that the dash is in fact a Unicode character (or something similar, I don't know much about character encodings).

2
  • 1
    Thank you. Looks like I was posting an answer at the same time as you. I accepted your answer.
    – MountainX
    Nov 12, 2017 at 8:15
  • Nice catch! Eagle-vision!!!
    – anon
    Nov 12, 2017 at 8:43
3

The whole strange problem was caused by the character in front of the rsync options. The problematic character is this one (and I don't know how it got there):

–
# printf – | od -An -vtu1
226 128 147

The proper character is this character, a standard dash (minus sign):

-
# printf - | od -An -vtu1
45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .