I'm thinking a shell script would be better, assuming you have SSH access to 
both servers. Something like: (typed straight into Mail disclaimer here)

#!/bin/bash
# Here I'm assuming that mysqldump, mysql, ssh and scp are all in the path

FILE=$(mktemp -t dump)
C_FILE=$(basename $FILE)
mysqldump -u username -ppassword database > $FILE

# Using public/private keys for the login process
scp $FILE u...@other-host:$C_FILE
ssh u...@other-host mysql -u user -ppasword other-databse < $C_FILE

On 17/08/2010, at 8:30 AM, Brendan Brink wrote:

> hi there,
> 
> Am wanting to automatically create a php script to create a copy of a
> database onto a different server.
> 
> The script would run each evening at midnight.
> 
> Unfortunately, we are not able to simply write each DB transaction to
> both databases on the fly.
> 
> The database has the following statistics:
> 
> 127 tables
> 237,000 rows
> 30MB in size.
> 
> It is a MYSQL5 database.
> 
> Does anyone know of a script they have used that can handle this?
> 
> Ideally want the database to be backed up to a functional secondary
> database, so that we can switch to it if the original server goes
> down, and hence the data would be new as at the last midnight.
> 
> Looking forward to your advice / information regarding this.
> 
> Thanks
> Brendan.
> 
> -- 
> NZ PHP Users Group: http://groups.google.com/group/nzphpug
> To post, send email to [email protected]
> To unsubscribe, send email to
> [email protected]

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e




-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]

Reply via email to