PDA

View Full Version : Need help writing a script in Linux.



Handruin
02-13-2002, 12:29 AM
I'm looking for help on writing a script in Linux and I will outline what I want to do with it below.

I would like the script to:

1- execute a backup of this database
mysqldump -uusername -ppassword databasename > sqldump.sql

2- rename the file so that the current date and time are placed at the end of the file. date formate to be Year/month/day/time (unless a better format should be used)

rn sqldump.sql phpbb2$current_date.sql

3- gzip the file
gzip -9 *.sql

4- move the file to a specific location and not leave anything remaining.

5- check for the last 5 backups and delete any remaining so that only the 5 most recent backups exist in this given directory including the newest file to be copied over.

I would then guess a Cron job could execute this script on a schedule, therefore creating an automated backup of the database into a specific location.

Does anyone know how to do this? Any advice appreciated.

-Doug

Mercutio
02-13-2002, 08:58 AM
I'll write up what you want this afternoon, after I get home from work.
Easy stuff.

Adcadet
02-16-2002, 05:30 PM
talk about sevice! Man this place can be good.

Mercutio
02-16-2002, 08:39 PM
Hmpf. Took me longer than I thought it would - I was looking at the date problem the wrong way, but the script itself is pretty easy to write.