Simple Backup script

Im trying to make this scrfipt work but its not...i cant any help?

#!/bin/sh

MYVHSTDESTDIR=/root/vhostsbackup/`date +%Y-%m-%d`
SOURCE=/home/httpd/vhosts

#Create our tempdir
mkdir $MYSQLDESTDIR

#Fill our tempdir with the DB's

cp  $SOURCE $MYSQLDESTDIR

#Create your backup in tgz
tar -czf /root/vhostsbackup/`date +%Y-%m-%d`backup.tgz $MYVHSTDESTDIR

#Create your backup in zip
zip -r  /root/vhostsbackup/`date +%Y-%m-%d`backup.zip $MYVHSTDESTDIR

#Remove our temp DB dir
rm -r $MYVHSTDESTDIR
LVL 2
MaRiOsGRAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nayernaguibCommented:
I think you used MYSQLDESTDIR twice instead of MYVHSTDESTDIR.

_______________

  Nayer Naguib
MaRiOsGRAuthor Commented:
ok now the script looks like :

#!/bin/sh

MYVHSTDESTDIR=/root/vhostsbackup/`date +%Y-%m-%d`
SOURCE=/home/httpd/vhosts

#Create our tempdir
mkdir $MYSQLDESTDIR

#Fill our tempdir with the DB's

cp  -r $SOURCE $MYSQLDESTDIR

#Create your backup in tgz
tar -czf /root/vhostsbackup/`date +%Y-%m-%d`backup.tgz $MYVHSTDESTDIR

#Create your backup in zip
zip -r  /root/vhostsbackup/`date +%Y-%m-%d`backup.zip $MYVHSTDESTDIR

#Remove our temp dir
rm -r $MYVHSTDESTDIR

but still it gives me tons of errors
MaRiOsGRAuthor Commented:
ok im totaly stupid ,
dont read my previous post :P
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

MaRiOsGRAuthor Commented:
now it works fine,
a last question
how do i make it to run on the cron
once per week at 5:00 in the morning ?
nayernaguibCommented:
1. Edit the file /etc/crontab
2. Add a line using the following syntax:

  minute hour dom month dow cmd

where dom=day of month,
          dow=day of week,
          cmd=command to execute.

In your case, the line would look like:

  0 5 * * 0 /path/script

where /path/script is the full path to the script you want to run.

Note: When specifying dow, 0 specifies Sunday, 1 Monday, ..., 7 Sunday.
         You can also use names (e.g., sun).

______________

  Nayer Naguib
MaRiOsGRAuthor Commented:
i have added this line :

*       2       *       *       7       /scripts/vhostsbackup.sh > /dev/null 2>&1

2 for 5 o clock (cause the server is a in different time zone) and 7 for doing the backup every sunday.

is that right ?
nayernaguibCommented:
You should specify 0 for minutes (so that the script will run at 2:00 am).
Modify the line as follows:

  0 2 * * 7 /scripts/vhostsbackup.sh > /dev/null 2>&1

You can check that the script will run as expected by temporarily changing the clock to 1:59 am on the server. Wait for 1 minute and see what happens.

_______________

  Nayer Naguib

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.