Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Perl MySQL backup - what's the best way?

by cosmicperl (Chaplain)
on Dec 13, 2007 at 15:49 UTC ( [id://656843] : perlquestion . print w/replies, xml ) Need Help??

cosmicperl has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
  I've got a script that's running on a few different shared hosting accounts. They use a mysql database and I'm trying to figure out what the best way to write a back and restore routine would be.
As these are on shared hosting so system calls (mysqldump, etc) are out, also some are on Win32 and others on Linux.
I'm assuming that there is a clever way of doing it without having to select and write each table to a text file or something. I was then planning on using Archive::Zip to compress the backup file.

Help much appreciated.


Lyle

Replies are listed 'Best First'.
Re: Perl MySQL backup - what's the best way?
by moklevat (Priest) on Dec 13, 2007 at 15:57 UTC
      Just found it. Looks like it'll do the job well. I'll look at updating it with an easy to use compression routine. Lyle
Re: Perl MySQL backup - what's the best way?
by bwelch (Curate) on Dec 13, 2007 at 16:25 UTC
    The mysqldump tool can be used to create backups of entire databases. Call it with something like this: mysqldump -h <host> -u <user> -p <db_name> > db_name.12.13.07.sql