in reply to Re: Using perl to automate mail backup
in thread Using perl to automate mail backup

Im not sure I gather what you mean a naming convention or simply cat to the tar. The tar files are created using a naming convention username-month-date-year.tar. I know it would be better to just tar /usr/spool/mail but I have a few mailboxes that are quite large (IMAP SERVER) and dont want to backup as frequently. Im going to modify the script to backup a few additional things (a few user directories, etc) so will probably have it tar something like:(PSEUDOCODE)

cd /var/spool/;tar -cvf /tmp/mail-bkup.tar $name1 $name2 .. cd /home; tar -cvf /tmp/user-bkup.tar $user1 $user2 .. cd /tmp; tar -cvf backup-$todays_date.tar mail-bkup.tar user-bkup.tar

Good point about checking the zip disk, I didnt think about that. The backup has been done, Just dont know on which disk!

Im not using modules such Archive::Tar because I am trying to better understand using perl as a glue language. I come from windows background and need the experience playing with the unix tools.

Currently the err checking is laughable, I know. This is just a test script that Im using from the command line and want to see whats going on. I think Ill take your sugestion and have it mail me any errors. How could I grab errors reported by tar and gzip? Can I grab standerr somehow?


Thanks!
zzspectrez

Replies are listed 'Best First'.
RE: RE: Re: Using perl to automate mail backup
by AgentM (Curate) on Nov 13, 2000 at 01:40 UTC
    If you open tar and gzip with IPC::Open3 or IPC::Run, then you'll be able to capture and use ALL 3 STD* pipes. I might reconsider using the Perl modules, though. While you might be able to mail yourself the STDERR from the failed tar, it might not always be obvious what happened. With the perl modules, this is less so. You should at least pick up on $? and turn on verbose mode on the tar and gzip.
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.