Re: Use PHP to copy MySQL tables
| From: | Justin Patrin | Date: | Fri, 09 Apr 2004 16:30:11 +0000 |
| Subject: | Re: Use PHP to copy MySQL tables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183008@lists.php.net to get a copy of this message | ||
Robb Kerr wrote:
Is there an easy way to create an HTML page that uses PHP to copy selected MySQL tables to backup copies on the same MySQL server? I want to create an administration page for my client to be able to "backup" their database whenever they see fit. But, I can't give them direct access to the MySQL server and don't want them backing up to their hard drive. I prefer to simply copy the tables to "backup" versions on the server so that if problems arise, I can log into the server and simply copy the "backups" to the originals. Thanx in advance.Well, here's what I would suggest....even though it's Linux specific (or at least mysql specific).
mysqldump -uusername -ppassword -Q database > /tmp/backup.sql;
mysql -uusername -ppassword backupDatabase < /tmp/backup.sql;
Or, if you feel like it, you can not to the file redirection and open a pipe to send the SQL back...
--
paperCrane <Justin Patrin>