On Fri, Oct 16, 2020 at 05:09:42PM -0500, Mike McClain wrote: > I've been using rsync to backup to a flash drive but it's not > performing exactly as I expected. I think Will nailed it. Your problem is not an rsync problem, but a shell (presumably bash) problem: [...] > A section of the backup script is so: > Params=(-a --inplace --delete); The above is setting a shell array (I guess it is a bashism (i.e. a bash specific idiom), but am too lazy to look up now). [...] > echo /usr/bin/rsync $Params --exclude-from=/home/mike/.rsync_exclude . $Flash/mike > /usr/bin/rsync $Params --exclude-from=/home/mike/.rsync_exclude . $Flash/mike || > echo rsync $Params --exclude-from=/home/mike/.rsync_exclude . $Flash/mike Failed $? ; And the above expands $Params to just the first element of the array (i.e. the "-a"). That's how bash arrays work. This is unfortunate, but that's how things are. Actually, the first of both lines above is an "echo": that's for you to see the actual rsync command as it's going to happen. If you look at your log file, you'll see that the --inplace and --delete are missing. If you want to have the whole array (space-separated) expanded, you'll have to do ${Params[@]}, as Will notes. Or -- much better -- don't use arrays here. Whoever wrote that script comes from Virtual Basic or Java or something similar. Arrays in shells may have their places, but this ain't one of those. Simply do: Params="-a --inplace --delete" then /usr/bin/rsync $Params [...] There is one thing I still don't understand about this script. Why does it invoke /usr/bin/rsync? Does the script writer know better where the "right" rsync lives? Or the sysadmin/user, who is in control of $PATH? Cheers - t
Attachment:
signature.asc
Description: Digital signature