You are not logged in.

#1 2011-07-27 16:47:24

crabman
Member
Registered: 2010-08-12
Posts: 30

rsync only newest 10gb of files

Hello,

Is it possible to make rsync sync only the newest files up to a total limit of 10gb?

My situation:
I have a music collection of 50gb and an mp3player that has 10gb of storage. What i want to do is copying only the 10gb of my collection to the mp3player that were accessed last. 

I was going to write some script using find and rsync but i am sure im not the first to encounter this problem.

crabman

Offline

#2 2011-07-27 17:13:16

llawwehttam
Member
From: United Kingdom
Registered: 2010-01-19
Posts: 181

Re: rsync only newest 10gb of files

I personally would use a while loop based on du -hs of mp3 player being less than 10Gb, copy files using cp, from a list determined using something else(not my area), probably the find command with -atime.

You really wouldn't have to use rsync and I see no point in doing so.

Also I would have thought this thread would be better in newbies corner.

If you read the forum guidelines/rules the arch community prefers if you do things for yourself, ie we are not really going to write all your scripts for you.

Last edited by llawwehttam (2011-07-27 17:17:23)

Offline

#3 2011-07-27 19:38:01

crabman
Member
Registered: 2010-08-12
Posts: 30

Re: rsync only newest 10gb of files

I want to keep a copy of the newest 10gb of 40gb of files in sync, so copy, delet and update these files. I thought rsync might be easier for that task.

I am willing/able to write a script like that myself, but since this is such a generic task i cannot imaginge there is no solution out there already. Probably something better than what i could come up within an evening of bash-coding.

crabman

Offline

#4 2011-07-27 19:48:56

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: rsync only newest 10gb of files

crabman wrote:

since this is such a generic task

Generic task? I really can't imagine that this is a very common use case...


ᶘ ᵒᴥᵒᶅ

Offline

#5 2011-07-27 19:50:50

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: rsync only newest 10gb of files

crabman wrote:

Probably something better than what i could come up within an evening of bash-coding.

An evening of bash-coding? Oh come on ;P

Offline

#6 2011-07-27 23:01:29

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: rsync only newest 10gb of files

My solution has always been has always been to use the built-in "format" command in my portable player's menu to wipe it, then just copy over the new stuff I've got from the folder I rip / download it to.  Not as quick-and-easy as a single script, sure, but hey:  I've bricked a player in the past by mucking around in the wrong way.  It's important to note that your 10-gig player probably only has 8.x gigs available after formatting, so there's a complication for ya.  You'd need to write up something specifically instructed not to go within a certain range limit (lest you end up with a fraction of an album just sitting there) and which won't screw with the device's firmware, as I'm guessing rsync isn't likely to find that in your music library.

Offline

#7 2011-07-31 05:50:52

zendeavor
Member
Registered: 2011-06-21
Posts: 11

Re: rsync only newest 10gb of files

rsync + find /path/to/music -atime sounds like *exactly* the solution you're after, actually. you'll just need one more bit of abstraction to limit transfer to ~8gb.

rsync is efficient at this kind of task, find knows how to find your music well, just need to sort by -atime and size, limit it to ~8gb and go. it will take a bit of learning, but i don't see any clearner or faster solution. you might be able to use the output from find to archive the music into a single folder and then extract that under your mp3 player, but i think rsync would still be better for the overall goal.

Offline

Board footer

Powered by FluxBB