Здравствуйте!
Преамбула:
mkdir /TEST
cd /TEST
for i in {a..c}; do : > $i; done
#!/usr/local/bin/bash
SOURCE="/TEST"
PATHTOBACKUP="/Volumes/BackUp"
date=`date "+%Y-%m-%dT%H:%M:%S"`
rsync -az --link-dest=$PATHTOBACKUP/current $SOURCE $PATHTOBACKUP/back-$date
unlink ${PATHTOBACKUP}/current
ln -s $PATHTOBACKUP/back-$date ${PATHTOBACKUP}/current
При первом запуске скрипта всё предсказуемо:
--link-dest arg does not exist: /Volumes/BackUp/current
unlink: /Volumes/BackUp/current: No such file or directory
ls -l /Volumes/BackUp/back-2017-03-05T14:19:44/TEST/a
-rw-r--r-- 1 ES wheel 0 5 мар 14:01 /Volumes/BackUp/back-2017-03-05T14:19:44/TEST/a
ls -i1 /Volumes/BackUp/back-2017-03-05T14:14:48/TEST/a
14083 /Volumes/BackUp/back-2017-03-05T14:14:48/TEST/a
ls -i1 /Volumes/BackUp/back-2017-03-05T14:19:44/TEST/a
14091 /Volumes/BackUp/back-2017-03-05T14:19:44/TEST/a
Что я делаю не так?
P.S.
О себе:
Darwin Kernel Version 13.4.0: Mon Jan 11 18:17:34 PST 2016; root:xnu-2422.115.15~1/RELEASE_X86_64
rsync version 3.1.2 protocol version 31
GNU bash, версия 4.4.12(1)-release (x86_64-apple-darwin13.4.0)