Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rsync delete files on sending side after transfer

Tags:

rsync

I want to download a large amount of data from a remote machine. I'd like the data to be erased on the remote machine everytime a file finishes downloading.

How do I do that? Is there a flag for rsync to do this?

like image 806
eran Avatar asked Jul 17 '14 10:07

eran


People also ask

How do I delete files after rsync?

For removing the files from the source after the transfer, the rsync command provides the –remove-source-files option.

Does rsync delete files on destination?

In its simplest form, the rsync command will copy files from the file source to the file destination. It will not remove files on the destination side that aren't on the source and it won't recreate all of the metadata (e.g., ownership and group details) unless your rsync command includes just the right set of options.

Does rsync Skip existing files?

Rsync with --ignore-existing-files: We can also skip the already existing files on the destination. This can generally be used when we are performing backups using the –link-dest option, while continuing a backup run that got interrupted. So any files that do not exist on the destination will be copied over.

What is rsync?

Rsync, which stands for remote sync, is a remote and local file synchronization tool. It uses an algorithm to minimize the amount of data copied by only moving the portions of files that have changed.


1 Answers

You need to pass the --remove-source-files option to the rsync command. It tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side. Do not pass the --delete option to rsync command as it delete extraneous files from destination directory. Delete source after successful transfer using rsync.

The syntax is:

rsync --remove-source-files -options /path/to/src/ /path/to/dest
rsync --remove-source-files -options /path/to/src/ computerB:/path/to/dest
rsync --remove-source-files -av /path/to/src/*.avi computerB:/path/to/dest

Reference : http://www.cyberciti.biz/faq/linux-unix-bsd-appleosx-rsync-delete-file-after-transfer/

like image 106
ganeshragav Avatar answered Oct 16 '22 22:10

ganeshragav