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 ?

4 Answers 4

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...

1
  • This is no good when you're doing a copy rather than a move. Sep 16, 2017 at 0:55
7

I do it using

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

for test and

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

for clear

-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.

-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.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .