[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: rsync --delete



On Fri, Oct 16, 2020 at 05:09:42PM -0500, Mike McClain wrote:
> Params=(-a --inplace --delete);
> Flash=/sda/rpi4b
> cd /home/mike

You forgot to check the result of this cd.  This is critically important;
if the cd fails, you do NOT want the script to continue.

cd /home/mike || exit

> [ ! -d $Flash/mike ] && mkdir $Flash/mike;

You should quote correctly, as a good habit, even in the cases where
you're expanding a variable with known content.

Also, you don't need the separate is-a-directory check.  You can replace
this line with:

mkdir -p "$Flash/mike"

> echo /usr/bin/rsync $Params --exclude-from=/home/mike/.rsync_exclude . $Flash/mike

You correctly made Params an array variable, but you didn't expand it
correctly.  Also, you missed quotes in two places.

Finally, using an explicit /usr/bin/rsync is sketchy at best.  You
should already have /usr/bin in your PATH.

echo rsync "${Params[@]}" --exclude-from=/home/mike/.rsync_exclude . "$Flash/mike"


Reply to: