#!/bin/bash clear echo echo "Minimal reproducible example (MRE)" echo "----------------------------------" echo echo "Tested with" echo "- rsync version 3.2.7 protocol version 31" echo "- ext4 file system" echo rm -rf MRE mkdir MRE cd MRE mkdir source touch source/read_only.txt chmod 444 source/read_only.txt mkdir snapshot1 # rsync --recursive --times --devices --specials --hard-links --human-readable -s --links --perms --executability --group --owner source/* snapshot1/ rsync --perms --executability --group --owner source/* snapshot1/ mkdir snapshot2 # rsync --recursive --times --devices --specials --hard-links --human-readable -s --links --perms --executability --group --owner --link-dest=../snapshot1 source/* snapshot2/ rsync --perms --executability --group --owner --link-dest=../snapshot1 source/* snapshot2/ # stat snapshot1/read_only.txt echo "File stats BEFORE rsync --delete": echo stat snapshot2/read_only.txt mkdir empty # delete snapshot1 using an empty source directory (shall be the fastest way to delete a subdir) # --debug=ALL rsync -a --delete -s empty/ snapshot1/ # rm -f snapshot1/ # works as expected (unlink does neither change 'Changed' time nor file permissions) # strace -c rm -rf snapshot1 echo stat snapshot2/read_only.txt echo echo "Results (after deleting snapshot1 via rsync --delete):" echo "1. The 'Change' time of the hardlinked file was updated" echo "2. The hardlinked file has now different access rights (644 instead of 444 so it is writable again!)" echo "This does NOT happen if 'rm -f snapshot1/' is used!" echo echo "Files in snapshot2:" ls -l snapshot2