dealing with renamed files
tomg at em.ca
Fri Jun 27 02:18:14 EST 2003
If I rename a directory full of files, or a bunch of files, and I use
Rsync to update the directory tree, Rsync will upload all these files
again and delete the old ones. This is suboptimal since all the data is
Rsync should be able to check for renamed files by scanning for files
with the same MD5 hashes, checksums, or delta signatures (is that what
you called them?). Rsync could then rename the files remotely and then
do the normal update.
Here is a shellscript implementation:
- Secure shell script
- Find out how to secure shell scripts
- Do filename escaping beforehand
- Provide Tar-like "-C" command line option
find -type f -print0 | xargs -0 md5sum > "$tmpfile"
for file in "$@" ; do
for new_line in `cat "$file"` ; do
new_md5=`echo "$new_line" | cut -d' ' -f1`
new_pathname=`echo "$new_line" | cut -d' ' -f3-`
old_pathname=`grep -m1 "$new_md5" "$tmpfile" | \
cut -d' ' -f3-`
if [ "$old_pathname" ] ; then
mkdir -p `dirname "$new_pathname"`
mv "$old_pathname" "$new_pathname"
Tom Goulet, tomg at em.ca, D8BAD3BC, http://web.em.ca/~tomg/contact.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/rsync/attachments/20030626/f1d5752a/attachment.bin
More information about the rsync