
|
View Full Version : php transfering files between sites?
acctman 11-01-2008, 09:13 PM whats the best method to transfer files from one site to another (at a later time another server). i'm not going with ftp since its not secure or reliable. i've looked into scp and rsync both would allow for me to move a users file after upload to a new location (domian) on the server. And, when it comes time to install a dedicated image server i'll just have to move the img domain and not have to change any coding. so scp or rsync which is better for writing a php file move code for, and if anyone has an example code that would be great.
thanks
NE-Andy 11-02-2008, 01:06 AM Rsync is better than scp if you need to keep files of two servers in sync. Else scp will do the trick for copying file from one location to another.
As far as coding goes, if it is your own server, you can enable exec() (http://www.php.net/manual/en/function.exec.php), and issue shell commands as per normal. As far as I'm aware of, there is otherwise no way to call rsync or scp via PHP.
exec('rsync or scp command here');
acctman 11-02-2008, 08:56 PM thanks, i'll go with scp
claymen 11-22-2008, 07:07 AM Have you looked at using unison? Its similar to rsync but imo is a lot easier to manage. We use this for a number of things at work and I personally use it to sync my photos between 3 machines (home linux box, work windows box and web hosting linux box).
It's open source and quite fast once the initial sync has completed.
JayShah 11-22-2008, 09:40 AM thanks, i'll go with scp
You'll probably need to setup keys for the script to SCP the file without expecting a password.
Jay
acctman 01-20-2009, 08:11 PM You'll probably need to setup keys for the script to SCP the file without expecting a password.
Jay
keys? can you explain. I need a secure and almost fail proof way to move uploaded images from one server to another. I've tried FTP and its not stable no matter which i've tried. I also need to be able to unlink (delete) a file with no problem
acctman 01-21-2009, 01:54 PM what the most stable method for moving files between servers? I have an image server where I want user images to be sent to after uploading. I tried the php ftp method with vsftp but it was stable enough to use. The connection wasn't stay up 24/7 there would be times where the connection would fail.
I was told to to look into nfs what are the pros/cons vs rsync? Image most be able to be unlinked for deleting as well as moving.
cygnusd 01-21-2009, 05:30 PM The stability problems you mentioned may need further investigation on your part. It could be that your host machine OR your datacenter network connection is problematic. I would say that first determine what's causing the problem instead of dismissing FTP. If vsftpd isn't up to your SLA requirements, OR worst, it crashes ... or if the host network is intermittent, I believe it warrants some investigation.
I understand that you have a separate server(s) intended to store the files uploaded by your users. There are a lot of ways to design a solution for this. Some alternative design I could think right now:
- how about that you allow the user to upload the file directly to your storage server via some php script. upon completed upload (or failure), you can tag a message to a shared database and have the php script on the storage server redirect back.
pros: direct upload to the storage server, no need to transfer
cons: requires you to expose your storage server, needs to be secured nonetheless. Needs more code.
- remote mounted file system approach, that is use a mounted remote FS directory where your php app writes the uploaded files. I'd recommend samba or NFS.
pros: also direct, no need to transfer, your php app does not need to be aware that the upload file goes to a remote machine.
cons: mounting should be automatic (or at least can easily be recovered) in case of crashes.
In any case, you need to monitor your host machine and host network. Having two (or more) machines increases risk of failure, there is always a chance to fail, no matter how small. Learn what's causing the failures and do something to fix them.
Cheers!
acctman 01-21-2009, 06:16 PM The stability problems you mentioned may need further investigation on your part. It could be that your host machine OR your datacenter network connection is problematic. I would say that first determine what's causing the problem instead of dismissing FTP. If vsftpd isn't up to your SLA requirements, OR worst, it crashes ... or if the host network is intermittent, I believe it warrants some investigation.
I understand that you have a separate server(s) intended to store the files uploaded by your users. There are a lot of ways to design a solution for this. Some alternative design I could think right now:
- how about that you allow the user to upload the file directly to your storage server via some php script. upon completed upload (or failure), you can tag a message to a shared database and have the php script on the storage server redirect back.
pros: direct upload to the storage server, no need to transfer
cons: requires you to expose your storage server, needs to be secured nonetheless. Needs more code.
- remote mounted file system approach, that is use a mounted remote FS directory where your php app writes the uploaded files. I'd recommend samba or NFS.
pros: also direct, no need to transfer, your php app does not need to be aware that the upload file goes to a remote machine.
cons: mounting should be automatic (or at least can easily be recovered) in case of crashes.
In any case, you need to monitor your host machine and host network. Having two (or more) machines increases risk of failure, there is always a chance to fail, no matter how small. Learn what's causing the failures and do something to fix them.
Cheers!
I think the mounting method would be best. is there a good example on how to mount with NFS, that you can direct me too?
Mike - Limestone 01-21-2009, 07:16 PM The stability problems you mentioned may need further investigation on your part. It could be that your host machine OR your datacenter network connection is problematic. I would say that first determine what's causing the problem instead of dismissing FTP. If vsftpd isn't up to your SLA requirements, OR worst, it crashes ... or if the host network is intermittent, I believe it warrants some investigation.
I understand that you have a separate server(s) intended to store the files uploaded by your users. There are a lot of ways to design a solution for this. Some alternative design I could think right now:
- how about that you allow the user to upload the file directly to your storage server via some php script. upon completed upload (or failure), you can tag a message to a shared database and have the php script on the storage server redirect back.
pros: direct upload to the storage server, no need to transfer
cons: requires you to expose your storage server, needs to be secured nonetheless. Needs more code.
- remote mounted file system approach, that is use a mounted remote FS directory where your php app writes the uploaded files. I'd recommend samba or NFS.
pros: also direct, no need to transfer, your php app does not need to be aware that the upload file goes to a remote machine.
cons: mounting should be automatic (or at least can easily be recovered) in case of crashes.
In any case, you need to monitor your host machine and host network. Having two (or more) machines increases risk of failure, there is always a chance to fail, no matter how small. Learn what's causing the failures and do something to fix them.
Cheers!
Very nice post :) The second solution seems ideal, as the security would be better.
-mike
|