Moving large file from one server to another server without downloading locally
Monday, July 11, 2011 16:07Here is the simple script to copy large file from one server to another server without downloading it to local machine.
<?php
$in = fopen("http://xyz.com/backup.tar.gz", "rb");
$out = fopen("backup.tar.gz", "w+");
echo pipe_streams($in, $out);
function pipe_streams($in, $out)
{
$size = 0;
while (!feof($in)) $size += fwrite($out,fread($in,8192));
return $size;
}
?>
Create a download.php in your destination server and change the filename to be downloaded and created.
It will avoid user’s bandwidth and time and it is the easiest way to copy the large backup files from one server to another server, while changing the hosting server.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Anton says:
July 26th, 2011 at 6:16 pm
Nice, short and working solution!
Transmitted 793 742 697b file less then a minute.
Thanks!