在实际生产中,老的NAS存储无法扩容,需要迁移到新的存储,种种原因只能前端迁移。
系统:Linux
容量:1.5T
为了减少对生产系统的影响。
1、提前将老的存储数据备份到新的存储上;
2、正试割接存储时,增量更新提前备份之后生成的目录及文件;
备份老的存储数据到新存储上shell。
#!/bin/bash # #20191211 #cp -a PATHOLD='/opt/old' PATHNEW='/opt/new' PATHLIST=' AA BB CC ' for OPATH in $PATHLIST do if [ ! -d $PATHOLD/$OPATH ];then echo "-----$PRO_PATH path no exist-------" >> mrice.log break else cp -a $PATHOLD/$OPATH $PATHNEW/ [ $? -eq 0 ] && echo "`date` ----$PATHOLD/$OPATH ok---- " >> mrice.log || echo "`date` ----$PATHOLD/$OPATH error----" >> mrice.log fi done
增量更新目录及文件。
#!/bin/bash # #20191211 #cp -a MTEMP='/opt' PATHOLD='/opt/old' PATHNEW='/opt/new' PATHLIST=' AA
BB
CC'
#file list for OPATH in $PATHLIST do if [ ! -d $PATHOLD/$OPATH ];then echo "-----$PRO_PATH path no exist-------" >> mrice.log break else cd $PATHOLD find $OPATH/* -type f -mtime -2 |xargs -i echo {} >> $MTEMP/mrice_temp$OPATH.txt echo "`date` ---$OPATH ----- find complete" >> $MTEMP/mrice1.log #cp file if [ -f $MTEMP/mrice_temp$OPATH.txt ];then for TEMPNAME in `cat $MTEMP/mrice_temp$OPATH.txt` do TEMPDIR=${TEMPNAME%/*} if [ -d $PATHNEW/$TEMPDIR ];then cp -a $PATHOLD/$TEMPNAME $PATHNEW/$TEMPDIR/ [ $? -eq 0 ] && echo "`date` ----$TEMPNAME ok---- " >> $MTEMP/mrice2.log || echo "`date` ----$TEMPNAME error----" >> $MTEMP/mrice2.log else mkdir -p $PATHNEW/$TEMPDIR cp -a $PATHOLD/$TEMPNAME $PATHNEW/$TEMPDIR/ [ $? -eq 0 ] && echo "`date` ----$TEMPNAME ok---- " >> $MTEMP/mrice2.log || echo "`date` ----$TEMPNAME error----" >> $MTEMP/mrice2.log fi done fi fi done