Jump to content

Server-to-server file transfers


Go to solution Solved by LLLLLLL,

Recommended Posts

(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...

Link to comment
https://forums.phpfreaks.com/topic/285428-server-to-server-file-transfers/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.