Jump to content


Photo

Server-to-server file transfers

ftp copy file server

Best Answer timneu22, 16 January 2014 - 08:12 PM

Ah yes, now I see ftp_connect and a bunch of related ftp_fput and stuff. That's the ticket. Thanks.

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 timneu22

timneu22

    Advanced Member

  • Members
  • PipPipPip
  • 264 posts

Posted 16 January 2014 - 06:04 PM

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



#2 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,709 posts
  • LocationBonita, FL

Posted 16 January 2014 - 07:54 PM

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.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#3 timneu22

timneu22

    Advanced Member

  • Members
  • PipPipPip
  • 264 posts

Posted 16 January 2014 - 08:12 PM   Best Answer

Ah yes, now I see ftp_connect and a bunch of related ftp_fput and stuff. That's the ticket. Thanks.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com