racingeg@shinbiro.com
¿Ö ¸¸µé¾ú³ª? Çѹ濡 ¾ÐÃàÇÒ·Á´Ù gzip ÀÌ 700~1000 mb »çÀÌ¿¡¼
Á×¾î¹ö¸®±â ¶§¹®¿¡, du ·Î µÚÁö¸é¼ ÀÛ¾÷Çß´õ´Ï ºÎºÐ º¹±¸ÇÒ¶§ ¹«Áö
±ÍÂú¾Æ¼.
ÆÄÀÏÀÌ ³Ê¹« ÂÉ°³Á®¼ ftp ·Î Àü¼Û½Ã ½Ã°£ÀÌ ³Ê¹« ¸¹ÀÌ °É¸±¼ö ÀÖ´Ù?
!!ÀÎÁ¤ÇÕ´Ï´Ù.
¾ÆÁ÷±îÁö »ý°¢À¸·Ð dir-list ÆÄÀÏÀ»º¸°í ÆÄÀÏ ¹øÈ£ °¡ ¸î¹øÀÎÁö º¸°í
±×ÆÄÀÏ Ã£¾Æ¼ º¹±¸ÇؾßÇÔ.
ÆÄÀÏÀ̸§¿¡ full-path ¸¦ ³Ö°Å³ª md5sumÀ» ³Ö´Â ¹æ¹ýµµ ÀÖÀ¸³ª ÆÄÀÏ º¸±â°¡ ´õ Èûµé¾îÁú±îºÁ ÇÏÁö¾ÊÀ½.
¾ÏÆ° ½É½ÉÇؼ ¸¸µé¾îº»°Å±¸¿ä <½ºÅæÇü´Ô JagÀÇ ÇãÁ¢ ½ºÅ©¸³ ²Ãº¸±â½ÈÀ½
Áö¿ì½Ã±æ >
____ ½ºÅ©¸³Æ® ÀÌÇØ°¡ Àß ¾È°¡½Ç²¨¿¡¿ä º¹ÀâÇÏ°Ô Â¥¼¸® ¹º°¡ Áú¹®ÀÖ´Ù?
¸ÞÀÏ º¸°í ³»Å°¸é ´ä¸á µå¸®ÁÒ.
¸®´ª½º°¡ ÁÁ¾Æ....
#!/bin/bash
# ""server_side_script_v2.sh"" backup file make script.
#
# !!! Important. all TARs dent has dirs so make dirs,
# before extract backupfiles maden by this.
# $1~2 BE MUST FULL PATH , or ERROR occured
# $1 :: backupfile's save point(dir)
# $2 :: listfile's name (that backupfile's list)
# precreate like this form. (ex. "/usr/local/apache" )
# I maden dirlist "find / -type d 2> /dev/null > LISTFILE"
# U have error make LISTFILE about "/" then make "/dirs" and
# concatenate files like this "cat LISTFILE1 LISTFILE2 > LISTFILE_ALL"
# begin verify arguments exist
if [ "$2" = "" ];then
echo
echo " !!! Important. all TARs don't has dirs so make dirs, "
echo " before extract backupfiles maden by this."
echo
echo " This script DO NOT check backup destination disk's space."
echo " You MUST STOP MANUALLY before DISKFULL."
echo " will upgrade this feature next 'v3' version."
echo
echo " argument 1~2 BE MUST FULL PATH , or ERROR occured"
echo " ARG1 :: backupfile's save point(dir)"
echo " ARG2 :: listfile's name (that backupfile's list)"
echo " precreate like this form. (ex. " 143 /usr/local/apache " )"
echo
echo " ---===INPUT ARGUMENTS COLLECTLY===--- "
echo
exit 1
# end verify arguments exist
fi
# notify start script.
echo -en "\n\t_<>_\n"
# begin make line No. contained DIRLISTFILE
cat -n $2 > $2"_LNC"
# end make link No. contained DIRLISTFILE
# begin SubDirNo ( 1 dir's capacity is about 17000 ~ 35000 )
subdirno=$(expr $(cat $2 | wc -l) / 10000)
i=0
while [ $i -lt $(($subdirno+1)) ]
do
mkdir $1/$i 2> /dev/null
i=$(($i+1))
done
# end SubDirNo
# /extra/ Manually start point.
if [ "`expr 0 + $3 2> /dev/null`" = "" ] ; then
i=0
else
i=`expr -1 + $3`
fi
####################################################
########### Main Loop part ####################
####################################################
while [ : ] ; do
:
i=`expr $i + 1`
#read oneline
curline=`tail +$i $2"_LNC" | head -1`
curno=`echo $curline | awk '{print $1}'`
curdir=`echo $curline | awk '{print $2}'`
#addition code for patch ( ERROR occured " " (space) contained DIR name )
curdir=`tail +$i $2 | head -1`
# begin EOF check
if [ "$curline" = "" ] ; then
echo -e "\n Script reached EOF. quit script."
exit 0
fi
# end EOF check
# begin /extra//extra/ Manually end point
if [ $curno -gt $(($4)) ] && [ $(($4)) != 0 ] ; then
echo -e "\n Script reached Manually END POINT. quit script."
exit 0
fi
# end /extra//extra/ Manually end point
echo -n $curno"_+"
# begin Blank curdir check 0 -> skip tar, 1 -> make tar.
if [ "$curdir" = "" ] ; then
# blank curdir check 0 's process
echo -en "\b_BRL_\t"
else
# blank curidr check 1 's process
cd "$curdir" 2> /dev/null
# Change Dir ERROR check. (echo error mesg and skip backup)
if [ $? = 1 ] ; then
echo -en "\b_CD_ERROR_\t\t\t"
# change dir error check's else ( NOW do backup )
else
find . -type d | tail +2 > curexcdirlist
tar zcf \
$1/$(expr $curno / 10000)/$curno"_"`hostname -f`"_"`date +
%Y%m%d`.tgz . \
--exclude-from=curexcdirlist --exclude=./curexcdirlist
#tar's error monitor start
if [ $? != 0 ] ; then
echo -e "\b\n TAR have ERROR. need Root's care. (
`date +%Y%m%d:%T`)"
fi
#tar's error monitor end
rm -f curexcdirlist
#make and append md5sum's contents
cd $1/$(expr $curno / 10000)/
md5sum $curno* >> md5sum.crc
# add prefix name to backupfile ,
# prevent tgz's deletion before md5sum completed
rename $curno c$curno $curno*
# delete "+" from stdout. this is useful checking backuplog.
echo -en "\b \b"
# change dir error check's fi
fi
# end BLANK curdir check
fi
done
# END OF SCRIPT
|