moved from subversion
This commit is contained in:
commit
952c48a3c8
|
@ -0,0 +1,5 @@
|
|||
# GeoNetwork 元数据缩略图单独备份与恢复工具
|
||||
|
||||
* 将GeoNetwork元数据的id转换为uuid
|
||||
* 备份对应的缩略图目录
|
||||
* 恢复缩略图为对应的id
|
|
@ -0,0 +1,33 @@
|
|||
#!/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 destination 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);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
if ($_SERVER["argc"]<4)
|
||||
{
|
||||
print "Usage: md-thumb-restore.php CSV_FILE BACKUP_DIR GN_DATA_DIR\n";
|
||||
print "\tCSV_FILE:\t the CSV format file which contain id and uuid column\n";
|
||||
print "\tBACKUP_DIR:\t the destination directory to backup\n";
|
||||
print "\tGN_DATA_DIR:\t the new Geonetwork data directory\n";
|
||||
die();
|
||||
}
|
||||
$csv=$_SERVER["argv"][1];
|
||||
$backup_dir=$_SERVER["argv"][2];
|
||||
$data_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)
|
||||
{
|
||||
$newdir=$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";
|
||||
$dir=$backup_dir.trim($duuid2[1]);
|
||||
@rrmdir($newdir);
|
||||
mkdir($newdir,0700,true);
|
||||
rename($dir,$newdir);
|
||||
}
|
||||
}
|
||||
function rrmdir($dir) {
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
|
||||
}
|
||||
}
|
||||
reset($objects);
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue