fsutil hardlink create <> <>
<?php // $dir = array(); $hah = array(); $hah_new = array(); $file = array(); $copy = 0; $link = 0; include 'conf.php'; $date = date('Ym-d'); // if(is_dir($date)){ exit("Backup already exists\n"); } // foreach(glob('*', GLOB_ONLYDIR) as $v){ if(is_file($v.'/hah.db')){ $hah = array_merge($hah, unserialize(file_get_contents($v.'/hah.db'))); } } // foreach($dir as $v){ $x = explode('/', $v); array_unshift($x, $date); $x[1] = substr($x[1], 0, 1); foreach($x as $k=>$v){ $y = implode('/', array_slice($x, 0, $k+1)); if(!is_dir($y)){ mkdir($y); } } } // while($n = array_pop($dir)){ if(!is_dir($date.'/'.substr($n, 0, 1).'/'.substr($n, 3))){ mkdir($date.'/'.substr($n, 0, 1).'/'.substr($n, 3)); } $dir = array_merge($dir, glob($n.'/*', GLOB_ONLYDIR)); $file = array_merge($file, array_diff(glob($n.'/*'), glob($n.'/*', GLOB_ONLYDIR))); } // foreach($file as $k=>$v){ $x = md5_file($v).filesize($v); if(!$x){ continue; } $f = $date.'/'.substr($v, 0, 1).'/'.substr($v, 3); if($hah[$x]){ exec('fsutil hardlink create "'.$f.'" "'.$hah[$x].'"'); $hah_new[$x] = $f; $link++; }else{ copy($v, $f); $hah_new[$x] = $f; $copy++; } print ceil($k*100/count($file))."%\r"; } print "\nLink: ".$link."\n"; print "Copy: ".$copy."\n"; // file_put_contents($date.'/hah.db', serialize($hah_new)); exit;
<?php date_default_timezone_set('Asia/Novosibirsk'); $dir[] = 'c:/scan'; // $dir[] = 'c:/web'; // $dir[] = 'c:/gohsrf'; // $dir[] = 'q:'; //
@echo off cls php backup.php pause
Source: https://habr.com/ru/post/135798/