3

I need to transfer file/files from one ftp to another. (automatically, let's say at midnight, when is server is less busy).

My question what my options are?

At the moment I'm reading how to use CRON and looking for php function to transfer files to external, and at the moment I'm not getting very far, I hope it's temporary. Would be nice to hear some advices.

Thank you, Max

MAX
  • 31
  • 1
  • 2
  • do you mean from one ftp server to an other ftp server? – Melsi Sep 21 '11 at 16:49
  • sorry that I haven't described about hardware. Computer A is a web server (VPS - linux) so people will upload files on 1 of the domains (php upload will filter executable files and will allow media only). Computer B is just password protected ftp server which will be used as storage) Computer A must transfer files to Computer B once a day to economy space on web server. About overriding: there will be tree folders divided by year, month, day, username. – MAX Sep 22 '11 at 14:43

2 Answers2

1

The question as stated appears to be about transferring files from one server to another automatically. The fact that these are ftp servers is incidental, since it is a very bad idea to use the same public-facing ftp service that clients use to fetch files to manage replication of said files (i.e. uploading new files and/or overwriting existing ones) - unless you really don't care about your system being hacked six ways to Sunday. PHP is not actually relevant at all, unless you have requirements that we don't know about from reading your question.

I would start by learning how rdist works. The general problem of synchronizing files across servers is decades old, and rdist has benefitted from a boatload of bugfixes and optimizations during that time. If you have more stringent security requirements (which seems unlikely since you're using ftp servers) then you may need to build a custom solution.

Peter
  • 2,526
  • 1
  • 23
  • 32
0

I would personally add a command to execute a shell script that uploads the files to a Cron table. I did a quick googlesearch and found a recursive script that does this. http://bash.cyberciti.biz/backup/copy-all-local-files-to-remote-ftp-server-2/

I do not take credit for the script. Hope this helps.

warbio
  • 466
  • 5
  • 16
  • thank you for your response, that looks very suitable for me as in my VPS (linux) there is both ssh and cronjob available. I think i'll try that. – MAX Sep 22 '11 at 14:35
  • From experience with filezilla client (not server) I have a small trick that might apply somewhere in you case. For directories of normal or small size (with many files inside) I used a php script to take a directory and store it to the desired destination as zip (is not about compression rate) then filezilla was working supper fast cause there was one file only to handle (the number of files is so important for it). Then with an other php script I unzipped it locally in a sec and this saved me a lot a lot of time. – Melsi Sep 22 '11 at 15:42