LPC:DUMP SE

Un article de lcgwiki.
Revision as of 11:32, 18 février 2010 by Chollet (talk | contribs)
(diff) ← Version précédente | view current revision (diff) | Version suivante → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The script given on that page is not completely correct, names may be partially/wrongly generated as it depends on the scan order.

  • 1st step: Snapshot of the Cns_file_metadata table
/usr/bin/mysql -u root -p...  -A > output << EOF
use cns_db;
select fileid, parent_fileid,name,filesize,filemode from Cns_file_metadata
EOF
  • 2nd step: Convert in XML format with full filename.
DATE=`date --iso-8601`
cat > atlas.syncat.xml << EOF
<?xml version="1.0" encoding="iso-8859-1" ?>
<dump recorded=" ${DATE} ">
<for>vo:atlas</for>
<entry-set>
EOF
awk '
BEGIN { Cache[0]=""; }

function FullName(id)
{
if (!(id in Cache)) {
  if (Parent[id] == 0)
    Cache[id]= IDName[id];
  else
    Cache[id]= FullName(Parent[id]) "/" IDName[id];
}
return Cache[id]; }
/^[0-9]/ { FILEID=$1; PARENTID=$2; NAME=$3; SIZE=$4; FILEMODE=$5;
         Parent[FILEID]=PARENTID;
         IDName[FILEID]=NAME;
         Taille[FILEID]=SIZE;                   
         Mode[FILEID]=FILEMODE;
       }
      END { for (id in Mode)
      if (Mode[id] > 30000)
        print FullName(id), Taille[id];
  }' output > output2
# Generate files under /dpm/in2p3.fr/home/atlas
 awk '// { print "<entry name=\"" substr($1, 2) "\"> <size>\"" $2 
"\"</size> <checksum></checksum> </entry>"; }' output2 | grep 
"/dpm/in2p3.fr/home/atlas" >> atlas.syncat.xml
cat >> atlas.syncat.xml << EOF
</entry-set></dump>
EOF