Page 1 of 1

How to sync folders

Posted: Tue May 17, 2005 2:27 am
by tiborv
Hello !

How can i rsync two folders over the web page ?
What is the command . Only in php or java.

Thanks !

Posted: Sat May 28, 2005 5:15 am
by JAM
This would be a start. Then you could just apply the basic file copy functions within the if-then-else statement of choise...

Code: Select all

<?php
    $dir1 = './1/';
    $dir2 = './2/';
    $arr1 = glob($dir1.'*');
    $arr2 = glob($dir2.'*');
    print_r($arr1); // debugging to...
    print_r($arr2); // ...show example output.

    foreach($arr1 as $file) {
        echo $file .' : '. filemtime($file) .'<br />';
    }
    foreach($arr2 as $file) {
        echo $file .' : '. filemtime($file) .'<br />';
    }
?>
Result:

Code: Select all

Array
(
    &#1111;0] =&gt; ./1/10b.txt
)
Array
(
    &#1111;0] =&gt; ./2/10b.txt
    &#1111;1] =&gt; ./2/alone.txt
)
./1/10b.txt : 1117275238
./2/10b.txt : 1117274932
./2/alone.txt : 1117275000

Posted: Sat May 28, 2005 5:33 am
by timvw
A little sample if you want to sync over ftp
http://timvw.madoka.be/comment.php?message_id=178


But you have asked this question already a few times, and my answer remains the same: Use the right tool for the right job. There are already a zillion of tools to sync (fe: rsync) that are specialized to do this... It would be silly to not use them.