13

I killed a local "rsync -ah" process.
It left junk files like ".abc.vmdk.zxivMN" in the target directory.
The junk files do not get deleted on consecutive "rsync -ah" runs.

Details:
I ran diff on both folders I was syncing and it reported: "Only in /mnt/archive1/documents/general: .abc.vmdk.zxivMN"

What is the best way to clean up the temporary rsync files ?

user27465
  • 259
  • 2
  • 7

4 Answers4

12

Tell rsync to delete files not on the source, with --delete-during or --delete-after. Be careful and use this option only if you don't have legitimate files on the target that aren't there on the source.

See man rsync.

Of course, you could always manually delete the files you detected with diff...

Sven
  • 98,649
  • 14
  • 180
  • 226
7

I do it using

find -type f -iname ".*.*.??????" -ls

for test and

find -type f -iname ".*.*.??????" -delete

for clear

TheKitoInc
  • 71
  • 1
  • 2
-1

I found the following command worked for me when trying to delete temp files left behind by rsync after a failed transfer.

find vod-content/ -path '*/.*' -print0 | xargs -0 -r rm -v

What this does is it finds all "hidden" files (files that begin with "." character) and passes them on to "rm" command to delete them.

A obvious known issue regarding the code above is if your contents contain hidden files then this command will delete those as well.

ipruthi
  • 51
  • 7
-2

I'm looking for a better solution but the only one I can think of is to move all empty files starting with a ., and having two further dots in them, to a trash folder (using rm is a bit risky):

find -type f -empty -iname ".*.*.*" | xargs -n 1 -d'\n' mv -v -t /tmp/

By no means foolproof.