4 messages in com.mysql.lists.win32RE: Backing up database from perl script
FromSent OnAttachments
Januski, Ken04 Jun 2002 10:12 
Greg Johnston04 Jun 2002 12:00 
Januski, Ken04 Jun 2002 12:34 
Januski, Ken04 Jun 2002 13:18 
Subject:RE: Backing up database from perl script
From:Januski, Ken (kjan@phillynews.com)
Date:06/04/2002 01:18:54 PM
List:com.mysql.lists.win32

Rod,

Your suggestion of a batch file with scheduler looks like it may be the best answer, esp. as it would allow the purge script to run immediately after the backup.

I really don't like to use system calls from Perl so this looks like it might be a much better solution.

Thanks again,

Ken

-----Original Message----- From: Rod Morris [mailto:ro@zmc.com] Sent: Tuesday, June 04, 2002 4:13 PM To: Januski, Ken Subject: RE: Backing up database from perl script

Hi,

I'd have the Windows scheduler run the scripts. That would be the easy way. Just make a batch file with:

mysqldump -u USERID -pPASSWORD --opt DATABASE > BACKUP_FILE.sql perl yourPurgeScript.pl

Schedule the batch file to run when desired and the purge won't start until the dump is complete. Alternately, coping the data dir is about the same as mysqlhotcopy:

xcopy z:\mysql\data\*.* e:\backup\mysql\data /D /S /E /C /I /H /R /K /Y

mysqldump is better though, I believe, as it will also do Innodb files. The problem with a perl system call is that I'm not sure that it wouldn't return prior to completely the script call.

At 03:34 PM 6/4/2002 -0400, you wrote:

Thanks Greg,

What I'm trying to do is find a way to run it from a perl script. I think I can do this with "system 'mysqlhotcopy.pl ....'" but I'm not sure that I can with "'system mysqldump -u USERID -p PASSWORD --opt DATABASE > BACKUP_FILE.sql'". That's really the nature of my question. I'm also not clear on which would be more useful for backups, the data directory that results from mysqlhotcopy.pl or the dump that comes from mysqldump.

-----Original Message----- From: Greg Johnston [mailto:john@magellantech.com] Sent: Tuesday, June 04, 2002 3:01 PM To: win@lists.mysql.com Subject: Re: Backing up database from perl script

I would use something like this, using backticks to run it from the command line.

`mysqldump -u USERID -pPASSWORD --opt DATABASE > BACKUP_FILE.sql`;

---------- Original Message ---------------------------------- From: "Januski, Ken" <kjan@phillynews.com> Date: Tue, 4 Jun 2002 13:12:31 -0400

Hi,

I'm wondering if anyone can give me any advice on backing up a database from within another perl script. I have a perl purge script that deletes files from file system based on age and updates records in database to say that they've been purged. What I'd like to do is backup the database before I run the purge script in case something goes wrong.

I've experimented a little with mysqlhotcopy.pl and could probably use a system call to run it from within the purge script. I'm just wondering if anyone knows of other options.

Thanks for any advice.