33 lines
958 B
PHP
33 lines
958 B
PHP
|
#!/usr/bin/php
|
||
|
<?php
|
||
|
if ($_SERVER["argc"]<4)
|
||
|
{
|
||
|
print "Usage: md-thumb-backup.php CSV_FILE GN_DATA_DIR BACKUP_DIR\n";
|
||
|
print "\tCSV_FILE:\t the CSV format file which contain id and uuid column\n";
|
||
|
print "\tGN_DATA_DIR:\t the old Geonetwork data directory\n";
|
||
|
print "\tBACKUP_DIR:\t the destincation directory to backup\n";
|
||
|
die();
|
||
|
}
|
||
|
$csv=$_SERVER["argv"][1];
|
||
|
$data_dir=$_SERVER["argv"][2];
|
||
|
$backup_dir=$_SERVER["argv"][3];
|
||
|
if (substr($data_dir,-1)!="/")
|
||
|
$data_dir.="/";
|
||
|
if (substr($backup_dir,-1)!="/")
|
||
|
$backup_dir.="/";
|
||
|
$fp=fopen($csv,'rb');
|
||
|
$dus=fread($fp,filesize($csv));
|
||
|
fclose($fp);
|
||
|
$duuids=explode("\n",$dus);
|
||
|
foreach($duuids as $duuid1)
|
||
|
{
|
||
|
$duuid2=explode(";",$duuid1);
|
||
|
if ($duuid2[0]>0)
|
||
|
{
|
||
|
$dir=$data_dir.sprintf('%05d',floor(($duuid2[0]+0.1)/100)*100).'-'.sprintf('%05d',ceil(($duuid2[0]+0.1)/100)*100-1)."/".$duuid2[0];
|
||
|
print $dir."\n";
|
||
|
$newdir=$backup_dir.trim($duuid2[1]);
|
||
|
rename($dir,$newdir);
|
||
|
}
|
||
|
}
|
||
|
?>
|