Shell script?


#1

So - I’m working on making a nice little shell script to dump mysql databases and then roll them up into a tar ball and ship them off to a web-accessable directrory.

I have a mysql dump working, but I would like it to create a file with the current date in it - like mysql.date.sql I read in the K-base in one of the user posts to
mysqldump… > filename.date +%Y%m%d
but when I do it simply puts out filename.date+%y%m%d. Can any one tell me what I should do?

I have created a simple text file with pico via SSH and named it backup.sh. It’s stored behind the web-accessable area and I set CHMOD to 700. My idea is to set up this script, and then once all is working the way I want - set up a cron job to excute this script once a week.

thanks!

-Matttail


#2

also while I’m asking questions, will doing this:
tar -cf mysql.tar backups/*
ball everything under the backups directory including subfolders?

thanks again!

-Matttail


#3

wow, I’m talking to my self on a forum…

I figured out my issue. I was typing ’ into pico when it is supposed to be ` (the charcter to the left of 1)

and I ended up writing it like this anyways:

suffix=$(date +%y%m%d)
mysqldump --opt -uuser -ppassword -h host.name db_name > mt3_backup.$suffix

Oh, and I tried using +%D instead of +%y%m%d becuase it was less typing, but that formats the date 4/14/05 and slashes are invald for file names.

So I’ve got it working now - but I’m posting this if anyone else has the problem later on. Thanks anyways!

-Matttail