wsdzbm
wsdzbm

Reputation: 3660

Update using rsync and remove from the source folder

I want to rsync contents from /local/path to server:/remote/path.

I tried

rsync -avmhP --include='*.[0-9][0-9][0-9][0-9]' --include='*/' --exclude='*' --size-only --remove-source-files /local/path server:/remote/path

However, some files existing in the remote path remain in local path.

Another question is, why we need --include='*/' --exclude='*'? Why --include='*.[0-9][0-9][0-9][0-9]' alone doesn't work for the file filtering?

Upvotes: 1

Views: 1009

Answers (1)

Flows
Flows

Reputation: 3863

Do you mean --remove-sent-file instead of remove-source-file ?

According to the rsync man page :

--remove-sent-file

This tells rsync to remove from the sending side the files and/or symlinks that are newly created or whose content is updated on the receiving side. Directories and devices are not removed, nor are files/symlinks whose attributes are merely changed.

That's means that only transferred file (the ones whom size changed) are deleted from source. To active the include file, you first need to exclude all the other BUT my include pattern. The 3 arguments you used mean "I excluded all files (--include='*/' --exclude='*') but the ones matching my pattern (--include='*.[0-9]{4}')

From man page :

--include=PATTERN

don’t exclude files matching PATTERN

--exclude=PATTERN

exclude files matching PATTERN

Upvotes: 1

Related Questions