LLLLLLL Posted January 16, 2014 Share Posted January 16, 2014 (As usual, this is a different type of question; if it's in the wrong forum please move it.) I own two domains: example.com and example.ru. These sites are essentially mirrors of each other but they provide better geo-awareness than having only one site. If I have files that I need to copy from example.com to example.ru on a semi-regular basis, how do I do this programmatically? Obviously I have the login credentials, nameservers, IP addresses, and whatever else of both servers. What's the code to accomplish this? I have not ever tried to send files from one server to another. It certainly would be better than FTPing the files down to a local machine and then FTPing back up to the other server. Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/285428-server-to-server-file-transfers/ Share on other sites More sharing options...
kicken Posted January 17, 2014 Share Posted January 17, 2014 Assuming these are linux servers with SSH access enabled, setup SSH keys for both servers to enable public-key-authentication between the two. Then you can use sftp or scp to transfer files between the two without having to enter password details. As a second option, regardless of OS, you could always just setup FTP servers on each and create a login for the other server to connect and send a file. Either of these options could be done directly from PHP code or you could exec() out to an external tool to handle the transfer. As a third alternative you could setup some kind of periodic sync to keep a certain directory in sync between the two servers. cront + rsync would be one way to handle this. There are other tools out there as well. Quote Link to comment https://forums.phpfreaks.com/topic/285428-server-to-server-file-transfers/#findComment-1465508 Share on other sites More sharing options...
Solution LLLLLLL Posted January 17, 2014 Author Solution Share Posted January 17, 2014 Ah yes, now I see ftp_connect and a bunch of related ftp_fput and stuff. That's the ticket. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/285428-server-to-server-file-transfers/#findComment-1465510 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.