Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 25th, 2005, 12:58 PM   #1
linuxpimp20
Hobbyist Programmer
 
Join Date: May 2005
Location: ma
Posts: 140
Rep Power: 4 linuxpimp20 is on a distinguished road
how to recursively copy or move part of a directory limited by size?

hi im trying to back up my system to do a fresh install. I have a directory named music where i ripped some of my cds. It is 2.2 gigs so i have to break it up to burn to cds as data files. I was wondering if there was any command i could use in a shell script that would be able to go thru that directory and splitting it up into directorys that are 600-700 mb to fit on a cd. The directory is set up like this ~/music/artist/album/files. I'd like the structure of the resulting components to be like the music folder - so i wouldn't want all the mp3s to be just tossed into 3 seperate folders. Any replies are appreciated. thanks in advance.
linuxpimp20 is offline   Reply With Quote
Old Jul 3rd, 2005, 3:40 PM   #2
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 335
Rep Power: 4 mackenga is on a distinguished road
I suggest:

tar -c music | gzip -9 > backup.tgz

That'll give you a nice compressed tarball for starters. MP3s don't squash down that much, though, but this does mean your hierarchy is nicely preserved for starters. Splitting this file into 700Mb (say) chunks is no problem; see the manpage for the split(1) command. Burn the chunks onto disks, then to restore your backup, copy the chunks back;

cat chunk2 >> chunk1
cat chunk3 >> chunk1
...
mv chunk1 backup.tgz
gunzip < backup.tgz | tar -xvf -

You can just cat them together because Unix won't mangle the contents when you do that. When you unpack the resulting tarball, your directory structure should be preserved. Hope this helps!
mackenga is offline   Reply With Quote
Old Jul 6th, 2005, 12:51 PM   #3
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
Quote:
Originally Posted by mackenga
I suggest:
tar -c music | gzip -9 > backup.tgz
this is simpler
gzip:
tar czvf backup.tgz music/
bzip:
tar cjvf backup.tgz music/
for the disk size discrimination you can use du and have a script that makes subdirectories up to some size and then do the tar on those directories
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC