rsync unknown filter rule merge -
i'm writing script using rsync synchronize 2 local folders. i'm building rsync command variables, set depending on whether .sync-filter
file exists or not.
here's sync
function:
function sync { from="$1" to="$2" local filter_file=${from%/}"/.sync-filter" local filter="" if [[ -f ${filter_file} ]] ; filter="--filter='merge ${filter_file}'" fi cmd="rsync -a --delete ${filter} ${from} ${to}" `$cmd` sleep 1 }
the result in terminal when running script:
execute command: rsync -a --delete --filter='merge ./.sync-filter' --exclude-from=./.sync-exclude . ../dst unknown filter rule: `'merge' rsync error: syntax or usage error (code 1) @ exclude.c(904) [client=3.1.1]
if manually run command, works no error.
anyone has clue?
after having same problem clue:
rsync expects (at least) filter-arg of command in own "argv" representation.
the bash-shell distinguishs following:
short test t.sh:
#!/bin/bash echo $1 echo $2 echo $3
test 1:
./t.sh b c
results in:
a b c
test 2:
./t.sh "a b" c
results in:
a b c
the called program (here t.sh) gets args in different way. question: rsync seems expect '--filter=...' in 1 "argv", means 1 argument in program.
i solved problem adding different parts of args further '"'. way first implementation should like:
cmd='rsync -a --delete "${filter}" ${from} ${to}'
Comments
Post a Comment