improve robustness of rsync copy function