Page 1 of 1

How can I delete big files with rsync?

Posted: 2020-06-17 06:41
by bester69
Hi,
I would like to remove in one instruction a folder by using filter size umbral.., how can i don this with rsync or find?

I'd like something like this, but I dont find the way: :roll:
:idea: rsync -av --delete --max-size=60M Movies/ Movies/



Any idea, thanks a lot.

Re: How can I delete big files with rsync?

Posted: 2020-06-17 07:22
by bester69
Perhaps I could do someting like this.:

cp -alvr Movies/* AllMovies/
cp -alvr Movies/* BigMovies/ && find BigMovies/ -type f -size -60M -exec rm {} \;
cp -alvr Movies/* SmallMovies/ && find BigMovies/ -type f -size +60M -exec rm {} \;

rsync -av --delete SmallMovies/ Movies/ (filter by small size movies)
or
rsync -av --delete BigMovies/ Movies/ (filter by big size movies)

:o

Re: How can I delete big files with rsync?

Posted: 2020-06-17 11:51
by cuckooflew
Some search foo maybe : used these key words:

Code: Select all

How to remove or delete files when using rsync 
UPDATE

As I find that the delete options are just for TARGET that if some files are removed from source, rsync --delete remove them from TARGET. And the delete option by after and before, as mentioned in its man page:

--delete-before receiver deletes before transfer, not during

Means that:

rsync delete the file from TARGET which are removed from SOURCE.
rsync start syncing files.

--delete-after receiver deletes after transfer, not during

Means that:

rsync start syncing files.
rsync delete the file from TARGET which are removed from SOURCE after syncing.

NOTE: The --delete-{before/after} implement just in TARGET.
Also

Code: Select all

man rsync 
is a very use full command. But off hand I don't know exactly cause I don't exactly understand what you want to do.
I use this :

Code: Select all

rsync [options] SOURCE TARGET
find TARGET -maxdepth 1 -type f -mtime +60 -exec rm -f {} \; 
Sometimes...

Re: How can I delete big files with rsync?

Posted: 2020-06-17 14:56
by bester69
cuckooflew wrote:..
rsync start syncing files.
rsync delete the file from TARGET which are removed from SOURCE after syncing.

NOTE: The --delete-{before/after} implement just in TARGET.
Also

Code: Select all

man rsync 
is a very use full command. But off hand I don't know exactly cause I don't exactly understand what you want to do.
I use this :

Code: Select all

rsync [options] SOURCE TARGET
find TARGET -maxdepth 1 -type f -mtime +60 -exec rm -f {} \; 
Sometimes...
Hi, Thanka for answering (we're talking about filtering by size not time :!: )

I wanted to make free local disk space for my MEGA movies folder collection... So ,I wanted to keep smaller movies than 40Mbytes and rest of them keep them in server side in a renamed folder VIDS_SERVER...

So, I wanted a rsync --delete with that keeps lower files han 40M for client side folder, and the opposite to rename in side server and take away from syncing in server MEGA side.

I was trying to rsync agains same folder for just applying max-size filter and purge filer bigger than XX size, the idea was this, but i dont know if it can be make it in just one step:

RSYNC --DELETE --MIN-SIZE=50M TARGET/ TARGET/

but using my purposed soltion and working with hardlinks made it : :o
Smallmoves goes to clien side
Bigmovies goes to server side (outisde sync)

cp -alvr Movies/* AllMovies/
cp -alvr Movies/* BigMovies/ && find BigMovies/ -type f -size -60M -exec rm {} \;
cp -alvr Movies/* SmallMovies/ && find BigMovies/ -type f -size +60M -exec rm {} \;

rsync -av --delete SmallMovies/ Movies/ (filter by small size movies)
or
rsync -av --delete BigMovies/ Movies/ (filter by big size movies)

Re: How can I delete big files with rsync?

Posted: 2020-06-17 15:14
by cuckooflew
Well if it works, that is what counts

Re: How can I delete big files with rsync?

Posted: 2020-06-17 17:36
by bester69
cuckooflew wrote:Well if it works, that is what counts
I always win, thats what it counts 8)