[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File archiving questions




I once wrote something similar to deal with a mail queue that kept filling up.  I wrote a script that every 10 minutes did a df and checked the partition that the mail queue was on.  Then, if it was more than 95% full, it would move messages out of the mail queue one at a time until df indicated that the partition was down to like (um I don't remember the actual numbers I used but say 80% full.)  Then, if the mail queue got below 50% full, it would start copying messages back in until it reached 90% or ran out of messages.  Well, it also had to deal with type enforcement issues, but that's basically what it did.

I suspect you could so something similar with the du command.


-----Original Message-----
From: KoReE [mailto:koree@ameth.org]
Sent: Wednesday, April 17, 2002 12:26 PM
To: SILUG
Subject: Re: File archiving questions


You could write a shell script using "du" to get the list of files you
want to copy.  Psuedocode would be something like:

du -k

Parse each file entry and stick it into an array of file names.
Also grab its size and stick that into a size var.

If an entry pushes the total size over 650MBs, drop the last file from
the array, and from the  size calculation, and go on to the copy
operation.

When it reaches 650MBs (650000KB)(or as close as possible based on the
above logic), stop, and do a copy to a specified dir, based on the entries
collected from "du -k".

perl may be better for this than a shell script.

Koree
____________________________________
Koree A. Smith  | Ameth Technologies
koree@koree.net | koree@ameth.org
     http://www.koree.net/

"With my feet upon the ground I move myself
between the sounds and open wide to suck it in,
I feel it move across my skin.
I'm reaching up and reaching out,
I'm reaching for the random or what ever will bewilder me.
And following our will and wind we may just go where no one's been.
We'll ride the spiral to the end and may just go where no one's been."

On Wed, 17 Apr 2002, Stephen D Reindl wrote:

> Oh you said not in a tarball. Upon further review.....nevermind!
>
> Steve
>
> On Sunday 14 April 2002 09:32 am, you wrote:
> > Hello!  Here's my situation:
> >
> > I have a directory, called "a", that has 15,500 files in it.  The total
> > bytes stored in the directory (as computed by executing command "du -sk a"
> > ) is 2.4GB.
> >
> > I wish to store these files on CD-ROM's.  I want them stored as "files" on
> > the CD-ROM's.  (i.e., not in a .tar or .zip or whatever).
> >
> > So... I figure I have to:
> >   1. Create a directory called "b".
> >   2. Copy about 650MB from "a" to "b".
> >   3. Create a .iso file by typing:
> >      mkisofs -o fred.iso -v -J -r b/
> >   4. Burn a cd by typing:
> >      cdrecord -v -eject dev=0,0,0 speed=12 fred.iso
> >   5. rm fred.iso
> >   6. rm -f b/*
> >   7. If there are still files left in "a", go to step #1.
> >
> > Easy, huh?  My problem is in step #2, above.  What's an easy way to copy
> > files from "a" to "b" and have the command STOP after 650MB have been
> > transferred?  I've been doing it manually, and that's NOT fun!
> >
> > Thanks!
> > Charlie Brune
> >
> > -
> > To unsubscribe, send email to majordomo@silug.org with
> > "unsubscribe silug-discuss" in the body.
>
> --
> ----- BEGIN GEEKCODE BLOCK-----
> GAT/ d- s+ a+ C++++ UL++>++++ P+>++++ L++>++++
> E--- W+ N++ w--- O- M-- PS+ PE Y+ PGP- t- 5 X R-
> tv+++ b- DI+++ D G++ e+>+++ h--- z-
> ------END GEEK CODE BLOCK------
> z-? h---? How odd!
>
> -
> To unsubscribe, send email to majordomo@silug.org with
> "unsubscribe silug-discuss" in the body.
>


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.