user2945770
user2945770

Reputation: 11

rsync --delete-after issues

Running on an OSX 10.9 box. In a bash terminal I am trying to copy files from dir a to dir b, deleting the files from dir a as they are copied over.

I am using the following command:

rsync -av --delete -after /a/* /b

The files from a copy over to b, but the files in a are still there after the transfer.

Upvotes: 1

Views: 10450

Answers (3)

JohnT
JohnT

Reputation: 127

If you are at all worried about inadvertently removing directories that didn't transfer correctly when using (from the previous post)

rm -rf /a/*

then you can use a slightly safer way of removing the empty sub-directories with 'find'.

rsync -av --remove-source-files /a/ /b/  && find /a/ -type d -empty -delete

Upvotes: 2

dtp70
dtp70

Reputation: 377

Try this:

rsync -av --remove-source-files /a/ /b/ && rm -rf /a/*

Upvotes: 0

StvnW
StvnW

Reputation: 1834

That's not what --delete does. --delete (and its variations like --delete-after) don't delete files from the source a, they delete files from the target b that do not exist in the source. The argument you are looking for is --remove-source-files.

Try rsync -av --remove-source-files /a/ /b/

Upvotes: 12

Related Questions