实现geonetwork中的缩略图的备份与恢复功能,需要数据库中的id和uuid

This commit is contained in:
wlx 2011-03-04 10:51:34 +00:00
parent f4689c4443
commit 266325d796
2 changed files with 66 additions and 0 deletions

33
tools/md-thumb-backup.php Executable file
View File

@ -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 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);
}
}
?>

33
tools/md-thumb-restore.php Executable file
View File

@ -0,0 +1,33 @@
#!/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 destincation directory to backup\n";
print "\tGN_DATA_DIR:\t the old 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]);
rename($dir,$newdir);
}
}
?>