HVRSYNC_CONF=${HOME}/.hv-rsync.conf
+RSYNC_DIFF_OPTS="-avun --itemize-changes --size-only --delete"
+
print_usage()
{
echo "${PROG_NAME} -- synchronisation serveur RSYNC"
# files, modification times, groups, owners, and permissions.
# -n: dry-run
+delete_target=""
+
+rsync_itemize_parser()
+{
+ local stdin
+
+ read -d '' -u 0 stdin
+
+ # Show lines starting with >, <, c, or * (deletions), effectively
+ # hiding entries that were only checked but not changed:
+ # grep -E '^([<>c\*])'
+ printf "%s\n" "$stdin" | \
+ grep -E '^([<>c\*])' | \
+ sed -e "s/^\*deleting\s\+/[${delete_target} DEL] /" | \
+ sed -e "s/^<[fLd][.cstpoaguax+]\{9\}/[SEND] /" | \
+ sed -e "s/^>[fLd][.cstpoaguax+]\{9\}/[RECV] /" | \
+ sed -e "s/^cd[.cstpoaguax+]\{9\}/[${delete_target} DIR]/"
+}
+
for f in ${rsync_list}; do
if [ x"${mode}" = x"diff" ]; then
fi
echo "Diff (push) for folder ${RSYNC_REMOTE_DIR}/${f}:"
-
- rsync -avun --delete \
- "${RSYNC_LOCAL_DIR}/${f}/" \
+ delete_target="REMOTE"
+ rsync ${RSYNC_DIFF_OPTS} "${RSYNC_LOCAL_DIR}/${f}/" \
${RSYNC_USER}@${RSYNC_SERVER}:"${RSYNC_REMOTE_DIR}/${f}" | \
- grep "^deleting "
+ rsync_itemize_parser
echo "Diff (pull) for folder ${RSYNC_REMOTE_DIR}/${f}:"
+ delete_target="LOCAL "
+ rsync ${RSYNC_DIFF_OPTS} ${RSYNC_USER}@${RSYNC_SERVER}:"${RSYNC_REMOTE_DIR}/${f}/" \
+ "${RSYNC_LOCAL_DIR}/${f}" | \
+ rsync_itemize_parser
- rsync -avun --delete \
- ${RSYNC_USER}@${RSYNC_SERVER}:"${RSYNC_REMOTE_DIR}/${f}/" \
- "${RSYNC_LOCAL_DIR}/${f}" | \
- grep "^deleting "
elif [ x"${mode}" = x"pull" ]; then
echo "RSYNC for folder ${RSYNC_REMOTE_DIR}/${f}:"
mkdir -p ${RSYNC_LOCAL_DIR}/${f}