I made a simple script to perform backup of my NAS. I do it as follows:
date="$(date +%Y-%m-%d)"
base="/backup"
newest="$(ls -1td "$base"/*-*-*/ | head -n 1)"
today="$base/$date"
dirs="pub,data,software"
if [ -d "$today" ]; then
echo "Backup already exists"
exit 1
fi
echo $newest
echo $dirs
mkdir "$today"
rsync -a --delete --info=progress2 "/myzpool/{$dirs}" "$today" --link-dest="$newest"
So what it is supposed to do is to create a folder with the name of the current date and then copy the folders /myzpool/pub, /myzpool/data and /myzpool/software into this newly created backup folder. But surprisingly, this does not work! rsync aborts with the error rsync: link_stat "/myzpool/{pub,data,software}" failed: No such file or directory.
I don't understand why this happens, because I use a very similar script to backup my virtual server via SSH:
dirs="srv,opt,home,root,etc"
mkdir "$today"
rsync -caz --compress-level=9 -e "ssh -i ~/.ssh/myserver.conf" --delete --info=progress2 "[email protected]:/{$dirs}" "$today" --link-dest="$newest"
and with the virtual server it works just fine. So what is the difference between the two command lines, and how could I fix my script, such that it also works locally?