Permissions and ownership not correctly synched
Opened this issue · 3 comments
Hi
When changing only permission and ownership in one side, bsync doesn't detect the modification and doesn't propagate it.
I'm doing it with a separate bash script: it synchronizes only files differents by permissions or ownership, and uses rsync and some trick to force synchronization in the right direction (I can't let rsync decide the direction of synchronization based on modification time, because obviously we need to check the change time).
Here is the bash script I'm using: probably not possible to use any of it to integrate in bsync, but I show just as an example. Also, this is a simple, not updated version, that only synchronize in one direction from remote to local.
#!/bin/bash
scriptname="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
local_path="$1"
remote_ip="$2"
remote_path="$3"
RSYNC_ARGS="$4"
[ -z "$RSYNC_ARGS" ] && RSYNC_ARGS="-a -A -X -z -E"
local_path="${local_path%%/}"
remote_path="${remote_path%%/}"
tmp_file="/tmp/${scriptname}_$RANDOM"
/usr/bin/rsync --rsync-path="rsync" $RSYNC_ARGS -ui -e "/usr/bin/ssh -C -i /root/.ssh/id_rsa -p 22" \
"$local_path/" root@$remote_ip:"$remote_path/" --dry-run | \
grep -Ev "^[^ ]*(c|s|t)[^ ]* " | \
grep -E "^[^ ]*(p|o|g|a)[^ ]* " | \
sed -e 's/^[^ ]* //' >"$tmp_file"
cd "$local_path"
cat "$tmp_file" | xargs -I {} stat -c '%n|%Z|%Y' "{}" | sort >"${tmp_file}.1"
cat "$tmp_file" | /usr/bin/ssh -C -i /root/.ssh/id_rsa -p 22 root@$remote_ip "cd \"$remote_path\" ; xargs -I {} stat -c '%n|%Z|%Y' \"{}\"" | sort >"${tmp_file}.2"
join -j 1 -t \| -o 1.1,1.2,2.2 "${tmp_file}.1" "${tmp_file}.2" | awk -F'|' '{if ($2 < $3) print $1}' | \
/usr/bin/rsync --rsync-path="rsync" $RSYNC_ARGS -ui -e "/usr/bin/ssh -C -i /root/.ssh/id_rsa -p 22" \
root@$remote_ip:"$remote_path/" "$local_path/" --files-from=-
rm -f "$tmp_file"*
Hello Stefano,
Thanks for sharing.
I wrote it in the README, in limitations: file ownership is ignored by bsync.
However, it should work for permissions. I was not able to reproduce it. Can you provide more info / steps to reproduce.
Thanks in advance,
Marc
You are right, permissions are correctly synched.
Do you think is a good idea to add support for ownership synchronization?
It should be pretty easy adding %U and %G format option to find command.
2016-02-18 21:07 GMT+01:00 Marc MAURICE notifications@github.com:
Hello Stefano,
Thanks for sharing.I wrote it in the README, in limitations: file ownership is ignored by
bsync.However, it should work for permissions. I was not able to reproduce it.
Can you provide more info / steps to reproduce.Thanks in advance,
Marc—
Reply to this email directly or view it on GitHub
#24 (comment).