0

I am wondering is it possible to create a PHP script to backup database on one server and then move the backup to an archive on the second totally different server.

So for example. A user access his/her online admin dashboard. In the list they have few sites lets say my-site-one.site and my-site-two.site. The user chooses to backup my-site-one.site so he or she click's a link which would use AJAX to trigger some sort of a file on there server and then run database backup.

Ones the database backup is done my-site-one.site sends the backup to my service where its securely stored under the user account.

This is probably will be a pain in the ass, but I can see few solutions.

  • Have a PHP script with API Key and User Key provided to the user and then have the user put this onto there server.
  • With my own site validate the PHP file along with API Key and User Key.
  • Have the PHPfile on user server make a backup to a static directory lets say /db-backups-##########.
  • With my site when command to backup is ran use CURL to check for /db-backups-########## and file located in it lets say db_dd-mm-yy_hh-mm.sql or .tar or .zip. With CURL fetch the file and store in on my own server.

Would this work or does anyone have a better idea how to do something like this? Or is it better to use PHP along with FTP?

Charles
  • 50,943
  • 13
  • 104
  • 142
Cl'
  • 1,535
  • 2
  • 10
  • 17
  • I'd suggest using streams instead of cURL, scheduling your data dump in off hours so it doesn't hammer your server responsiveness, and plan for the inevitability that the database files may be large and take longer than the normal PHP timeout to transfer and thus PHP is probably a weak link at that stage. – Jared Farrish Dec 09 '12 at 04:33
  • And FTP is probably a better option. Why not use shell prompts to do that and leave PHP out of the transfer altogether (assuming some kind of *nix, of course)? – Jared Farrish Dec 09 '12 at 04:36
  • Here's a related question: http://stackoverflow.com/questions/1397182/stream-ftp-download-to-output – Jared Farrish Dec 09 '12 at 04:38
  • @JaredFarrish the problem is that I am building a online Admin resources service. So far I have ability to edit site files via using PHP and FTP and Analytic data via PHP and JS. Now I was thinking if I can allow users to make a Database backup and dump it to my servers which well in terms dump the content to Amazon S3. If PHP is not a good solution would you think RoR can do a better job of this? – Cl' Dec 09 '12 at 04:38
  • So you want your users to use admin tools that reside on your server to contact their server and ask for a database dump file, which your system's server will retrieve and store somewhere on your system? Is that right? Also, are you considering the security of the data file, since it sounds like you're planning to put that file (a snapshot of a database) on a web-accessible path for your script to access? And I would think (but don't know) that Ruby on Rails would probably be a *worse* choice; maybe Python? Consider that shells have functions that are fast and dedicated to this, like Wget. – Jared Farrish Dec 09 '12 at 07:37

0 Answers0