in reply to Simple Backup Script

Here is a shell script, it assumes your directory list is in a file called dirlist which can be changed easily.

#!/bin/sh date=`date +%d%m%Y` for x in `cat dirlist` do y=`basename $x` tar zcvf $y-${date}.tar.gz $x done

The same basic structure can be rewritten in perl or you can go the whole Archive::Tar route and really make it complex:D

Good luck

Replies are listed 'Best First'.
Re: Re: Simple Backup Script
by Llew_Llaw_Gyffes (Scribe) on May 07, 2003 at 21:04 UTC
    Or, without a static list file:
    #!/bin/sh date=`date +%d%m%Y` for x in $* <---- here's the only change needed! do y=`basename $x` tar czvf $y-${date}.tar.gz $x done
    You could even make this a shell function in your .bash_profile or .bashrc, like so:
    function maketar { date=`date +%d%m%Y` for x in $* ; do y=`basename $x` tar czvf $y-${date}.tar.gz $x done } export -f maketar
    There's (wait for it!) "More Than One Way To Do It." Even before you get into doing it in Perl. :)