Chinaunix首页 | 论坛 | 博客
  • 博客访问: 74262
  • 博文数量: 47
  • 博客积分: 1230
  • 博客等级: 中尉
  • 技术积分: 525
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-22 13:59
文章分类

全部博文(47)

文章存档

2012年(9)

2011年(38)

分类: LINUX

2011-04-26 18:54:41

1.mount命令的用法(基本解决);

 mount -t cifs -o username=guest,password=st //10.167.226.209/ba

ckup  /mnt/jhj

2.调整虚拟机中linux分辨率和主操作系统一致;(基本解决)

3.错误信息的输出和备份成功与否的判断;(已解决:$?命令的返回码;2>>log输出错误信息到文件;

①如何调整分辨率:

http://hi.baidu.com/hovlj_1130/blog/item/619e36d4c46706cf51da4be4.html

linuxwindows共享目录的访问:

cdpushd popd的不同。

最后用的是cd,popd自动会弹出东西。

#!/bin/bash

#Function:backup directory 'data' to dest 'qvbackp'

#Date:2011 04 25

#Version:1.0.0.0

 

  declare -i count=$#

# step1:backup and move backuped files to another directory

  case $count in

     "1")                  

        if [ "$1" == "--help" ] ; then

           echo "Usage: qvbackup.sh    SOURCE-DIRECTORY    DEST-DIRECTORY"

           echo "Backup files of SOURCE-DIRECTORY to DEST-DIRECTORY."

           exit

        else

           echo "Invalid parameters, make sure all parameters are correct. "

           exit

        dfi

  ;;

      "2")               

          if [ ! -d $1 ] ; then

             echo "No such file or directory"

             exit

          elif [ ! -d $2 ] ; then

             mkdir -p $2

          fi

         

           srcdir=$(dirname $1)

           srcname=$(basename $1)        

           destdir=$2

           destname=$(basename $2)

           destdir="${destdir%/}/" 

           # setp1.1:when today is the first day of the month,

           # the programme will move the all the backuped file

           # to another directory.

             if [ $(date +%d) == "01" ] ; then

                if [ $(whereis -b "$destname$(date +%d)") ] ; then

                   cd $(dirname $destdir)

                   rm -rf  "$destname$(date +%d)" 1>/dev/null 2>>"${destdir}qvbackup.log"

                  

                fi 

                cd $(dirname  $destdir)

                   mv  "$destname"  "$destname$(date +%d)"

                   mkdir -p $2

                

             fi

           # step1.2:backup files of SOURCE-DIRECTORY to

           # DEST-DIRECTORY

             backupfile="$(date +%Y-%m-%d-%H-%M-%S)_$srcname.tgz"

             destfile="$destdir$backupfile"    

             cd  $srcdir

               tar -g "${destdir}snapshot" -zcf $destfile  $srcname 1>/dev/null 2>>"${destdir}qvbackup.log"

               retCode=$?

            

         

  ;;  

      "0")           

         echo "No parameters, please make sure."

         exit

  ;;

       *)            

         echo "Too more parameters, please make sure."

         exit

  ;;

 esac

 

# setp2:output backup log ,backup information and recover scripts

rstMsg=""

cd $destdir

if [ "$retCode" == "0" ] ; then

   rstMsg="$(date +%Y-%m-%d-%H-%M-%S) backup OK"

   echo "tar zxf $destfile">>qvrecover.sh

else

   rstMsg="$(date +%Y-%m-%d-%H-%M-%S) backup ERROR" 

fi

   echo $rstMsg>>qvbackup.log

 

   echo $rstMsg

exit 0

阅读(729) | 评论(0) | 转发(0) |
0

上一篇:0426

下一篇:20110513装postgreSQL

给主人留下些什么吧!~~