Forum Moderators: coopster & phranque

Message Too Old, No Replies

MYSQL backups using CGI and Perl

MYSQL backups using CGI and Perl

         

cormac moylan

11:58 am on Apr 15, 2006 (gmt 0)

10+ Year Member



Hello, i've never used either of these technologies before so pardon my ignorance if some of my questions seem odd!

Basically i'm looking for a system whereby i can automatically create backups of a mysql database and store the backup as a .sql file(or similar).

There is a folder called cgi-bin in the root of my hosting account. I came across a tutorial entitled "How to backup your MySQL tables and data every night using a bash script and cron".

Within the tutorial a emailsql.cgi file is created, which is placed into the cgi-bin folder but also a Bash Shell Script is mentioned called mysqlbackup. What do i do with the mysqlbackup script? it doesn't say to give it a file extension or anything.

Can you save shell scripts as .cgi too?

adwatson

3:17 pm on Apr 16, 2006 (gmt 0)

10+ Year Member



I backup my databases by using a perl script that loops thgrough an array of database names. I then use the mysqldump program to "dump" the database out to the a filename that I generate based on the database name and the date... The mysqldump command looks something like

mysqldump --opt [database name] > [backup file].sql

Then my backup script compresses the sql file with gzip.

I have it set up on a cron job to run nightly.

I suppose you could just do cron job for the above command to get what you're looking for.

Robber

1:35 pm on Apr 20, 2006 (gmt 0)

10+ Year Member



I use a simlar system to adwatson, just an extra step involved. I have a second perl script running on my local system that uses Net::SFTP to download the backup at set intervals, this is run as a cron each morning.