国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > Linux通過shell腳本怎么備份系統(tǒng)

    Linux通過shell腳本怎么備份系統(tǒng)

    時間: 春健736 分享

    Linux通過shell腳本怎么備份系統(tǒng)

      對于如何在Windows系統(tǒng)上面怎么進(jìn)行系統(tǒng)備份相信大家都知道,那么大家知道Linux通過shell腳本怎么備份系統(tǒng)嗎?學(xué)習(xí)啦小編分享了Linux通過shell腳本備份系統(tǒng)的方法,希望對大家有所幫助。

      Linux通過shell腳本備份系統(tǒng)方法

      腳本如下:

      #!/bin/sh

      #Automatic Backup Linux System Files

      #Author wugk 2013-11-22

      #Define Variable

      SOURCE_DIR=(

      $*

      )

      TARGET_DIR=/data/backup/

      YEAR=`date +%Y`

      MONTH=`date +%m`

      DAY=`date +%d`

      WEEK=`date +%u`

      FILES=system_backup.tgz

      CODE=$?

      if

      [ -z “$*” ];then

      echo -e “Please Enter Your Backup Files or Directories\n--------------------------------------------\nExample

    學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > Linux通過shell腳本怎么備份系統(tǒng)

    Linux通過shell腳本怎么備份系統(tǒng)

    時間: 春健736 分享

    Linux通過shell腳本怎么備份系統(tǒng)

      對于如何在Windows系統(tǒng)上面怎么進(jìn)行系統(tǒng)備份相信大家都知道,那么大家知道Linux通過shell腳本怎么備份系統(tǒng)嗎?學(xué)習(xí)啦小編分享了Linux通過shell腳本備份系統(tǒng)的方法,希望對大家有所幫助。

      Linux通過shell腳本備份系統(tǒng)方法

      腳本如下:

      #!/bin/sh

      #Automatic Backup Linux System Files

      #Author wugk 2013-11-22

      #Define Variable

      SOURCE_DIR=(

      $*

      )

      TARGET_DIR=/data/backup/

      YEAR=`date +%Y`

      MONTH=`date +%m`

      DAY=`date +%d`

      WEEK=`date +%u`

      FILES=system_backup.tgz

      CODE=$?

      if

      [ -z “$*” ];then

      echo -e “Please Enter Your Backup Files or Directories\n--------------------------------------------\nExample

    /boot /etc 。。。。。。”

      exit

      fi

      #Determine Whether the Target Directory Exists

      if

      [ ! -d $TARGET_DIR/$YEAR/$MONTH/$DAY ];then

      mkdir -p $TARGET_DIR/$YEAR/$MONTH/$DAY

      echo “This $TARGET_DIR is Created Successfully !”

      fi

      #EXEC Full_Backup Function Command

      Full_Backup()

      {

      if

      [ “$WEEK” -eq “7” ];then

      rm -rf $TARGET_DIR/snapshot

      cd $TARGET_DIR/$YEAR/$MONTH/$DAY ;tar -g $TARGET_DIR/snapshot -czvf $FILES `echo ${SOURCE_DIR[@]}`

      [ “$CODE” == “0” ]&&echo -e “--------------------------------------------\nThese Full_Backup System Files Backup Successfully !”

      fi

      }

      #Perform incremental BACKUP Function Command

      Add_Backup()

      {

      cd $TARGET_DIR/$YEAR/$MONTH/$DAY ;

      if

      [ -f $TARGET_DIR/$YEAR/$MONTH/$DAY/$FILES ];then

      read -p “These $FILES Already Exists, overwrite confirmation yes or no ? : ” SURE

      if [ $SURE == “no” -o $SURE == “n” ];then

      sleep 1 ;exit 0

      fi

      #Add_Backup Files System

      if

      [ $WEEK -ne “7” ];then

      cd $TARGET_DIR/$YEAR/$MONTH/$DAY ;tar -g $TARGET_DIR/snapshot -czvf $$_$FILES `echo ${SOURCE_DIR[@]}`

      [ “$CODE” == “0” ]&&echo -e “-----------------------------------------\nThese Add_Backup System Files Backup Successfully !”

      fi

      else

      if

      [ $WEEK -ne “7” ];then

      cd $TARGET_DIR/$YEAR/$MONTH/$DAY ;tar -g $TARGET_DIR/snapshot -czvf $FILES `echo ${SOURCE_DIR[@]}`

      [ “$CODE” == “0” ]&&echo -e “-------------------------------------------\nThese Add_Backup System Files Backup Successfully !”

      fi

      fi

      }

      Full_Backup;Add_Backup

      上面就是Linux使用shell腳本備份系統(tǒng)的方法介紹了,通過上面的腳本就能自動備份系統(tǒng),但腳本可能還存在不足的地方,可自行改良優(yōu)化。

    看過“Linux通過shell腳本怎么備份系統(tǒng)”的人還看了:

    1.怎么在windows系統(tǒng)中使用linux的shell腳本

    2.linux系統(tǒng)怎么備份

    3.linux系統(tǒng)備份命令是什么

    4.如何查閱Linux系統(tǒng)正在使用的Shell版本

    5.Linux中rsh怎么遠(yuǎn)程使用shell命令

    6.Linux文件權(quán)限怎么備份和恢復(fù)

    1095671