Kermit911
3-11-05, 08:09 AM
Is there a way I can restore an entire folder from the snap shot insted of 1 file at a time? Or restore the whole snap shot?
Thanx
Hopefully it's fine to post this. I got the function off the internet, and added a bit of code at the bottom.
Replace the x/xxxx and "directory" / "directory2" with the correct paths. I didn't want to see what would happen if I tried to overwrite the existing directory, so I just gave it a new name. It's easy to delete the old one and change the name afterwards, or you can modify the code if you want. nightly.0 means it restores yesterday's, if you want it from the day before use nightly.1, etc.
Save it as a php file, run it from a browser. Worked when I tested it, hope it works for you. :)
P.S. I don't actually know anything about php; leaving this file on the server may compromise your security, especially if anyone has permission to execute it. To be safe you should delete it after you use it.
<?php
////////////////////////////////////////////////////////
/// cp function/////////////////////////////////
////////////////////////////////////////////////////////
function cp($wf, $wto){ // it moves $wf to $wto
mkdir($wto,0777);
$arr=ls_a($wf);
foreach ($arr as $fn){
if($fn){
$fl="$wf/$fn";
$flto="$wto/$fn";
if(is_dir($fl)) cp($fl,$flto);
else copy($fl,$flto);
}
}
}
///////////////////////////////////////////////////
/// ls_a function////////////////////////
// This function lists a directory.
// ANd is needed for the cp function.
function ls_a($wh){
if ($handle = opendir($wh)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." ) {
if(!$files) $files="$file";
else $files="$file\n$files";
}
}
closedir($handle);
}
$arr=explode("\n",$files);
return $arr;
}
cp("/www/.snapshot/nightly.0/x/xxxx/htdocs/directory", "/www/x/xxxx/htdocs/directory2");
?>
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.