LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Shell Script for Gzipping with date output (http://www.linuxquestions.org/questions/programming-9/shell-script-for-gzipping-with-date-output-243356/)

Junior41180 10-16-2004 06:33 AM

Shell Script for Gzipping with date output
 
Hi, I got a cron job already set up for doing a mysqldump (Via cPanel), now what i need to do is create a shell script to gzip the DB dump and output the file name to filename-xx-xx-xxxx.sql.gz

Does anyone know if there is a already configured script for this, or does anyone know what the script should be??


Thanks.

Sorry if this is the wrong forum for this. :)

darthtux 10-16-2004 06:39 AM

This is one I wrote a while back. You'll just need to edit it a little.

#!/bin/sh

echo "Enter directory name"
read arg1

CURRDIR=$arg1
DATE=`date +%Y%m%d`
DESTDIR=$CURRDIR"$DATE"
mkdir "$DESTDIR"

cp -r $arg1/* $DESTDIR
tar czvf $DESTDIR.tar.gz $DESTDIR
rm -rf $DESTDIR


All times are GMT -5. The time now is 05:37 AM.