Can rclone copy *only* new files to destination, but never delete from source?

I’m looking to copy only new files from the source to the destination without deleting any files from the source.

Essentially, I’d like new files to be created on the source. Say the source contains files A and B and the destination has nothing. It should copy files A and B to the destination - obviously.

Source     |     Dest
 A B       |     A B 

But what if I delete A and B from the destination and add file C to the source? I’d ultimately like that to look like this:

Source     |     Dest
A B C      |      C 

Is that possible with rclone? I’d like to eventually create a cron job to periodically check this and sync.

Your question is confusing.

Sync never deletes files from SOURCE. It only deletes files from DEST. Sync does exactly what is implied. It makes DEST match exactly what is in SOURCE.

If you don’t want anything to be deleted in DEST, use rclone copy

Imagine you had a seedbox (source) and you wanted it to copy files to your desktop PC (destination), but you wanted to keep the remote files (source) on the seedbox to continue seeding regardless of the changes made on your local PC. So, on your desktop PC (destination) you could delete, move, or otherwise manipulate those files without those files being continuously copied back to the PC by rclone.

Rclone would only copy new files from the seedbox that haven’t previously been copied to the PC.

You might be able to do this using rclone copy and --max-age - rclone needs some way of choosing between the A,B,C.

2 Likes

To accomplish what you’re asking, I would write a wrapper script that uses the COPY functionality to copy files from SOURCE to DEST. After the copy is complete, I would write the directory listing to a file and then use --exclude-from option to exclude those files that exist in that file you just created when you run subsequent copies. That way, files that were copied the last time around wont be copied again.

1 Like

If you’re on Unix then something like:

cd $SOURCE_DIR
touch $HOME/.rclone.timestamp.new
find . -type f -newer $HOME/.rclone.timestamp -exec rclone .... <stuff goes here>
mv $HOME/.rclone.timestamp.new $HOME/.rclone.timestamp

That would only copy files that were touched since the last script execution, but you might need to be slightly clever in the <stuff goes here> part :slight_smile:

3 Likes

I’m super new to Unix, how exactly would I go about using this?