23.07.2014 Views

Lustre 1.6 Operations Manual

Lustre 1.6 Operations Manual

Lustre 1.6 Operations Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

27.2 A Simple Data Migration Script<br />

#!/bin/bash<br />

# set -x<br />

# A script to copy and check files<br />

# To guard against corruption, the file is chksum'd<br />

# before and after the operation.<br />

# You must supply a temporary directory for the operation.<br />

#<br />

CKSUM=${CKSUM:-md5sum}<br />

MVDIR=$1<br />

if [ $# -ne 1 ]; then<br />

echo "Usage: $0 "<br />

exit 1<br />

fi<br />

cd $MVDIR<br />

for i in `find . -print`<br />

do<br />

# if directory, skip<br />

if [ -d $i ]; then<br />

echo "dir $i"<br />

else<br />

# Check for write permission<br />

if [ ! -w $i ]; then<br />

echo "No write permission for $i, skipping"<br />

continue<br />

fi<br />

OLDCHK=$($CKSUM $i | awk '{print $1}')<br />

NEWNAME=$(mktemp $i.tmp.XXXXXX)<br />

cp $i $NEWNAME<br />

RES=$?<br />

if [ $RES -ne 0 ];then<br />

echo "$i copy error - exiting"<br />

rm -f $NEWNAME<br />

exit 1<br />

fi<br />

Chapter 27 <strong>Lustre</strong> Operating Tips 27-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!