Interactive Scripting example-data backup

Source: Internet
Author: User

#!/bin/bashread -p  "do you want to backup file or directory[file/ Directory]: " OPTIONread -p " What is you backup[absolute location and  name]: " BACKUPcase  $OPTION  in         file)             read -p  "what is  Your backup to dir (absolute location): " TODIR1             read -p  "What is your backup name:"   name1             if [ -e $ todir1/$NAME 1 ];then               read -p  "do you want to change name[yes/no]:"  CHNAME1               case  $CHNAME  in                    yes)                       read -p   "What is you change names:"  CHNAMES1                      mv  $TODIR 1/$NAME 1   $TODIR 1/$CHNAMES 1                      echo  "Change success"                       cp  $BACKUP  $/todir1/$NAME                     ;;                     NO)                       exit 1                    ;;                esac               else                mkdir  $TODIR 1                cp  $BACKUP   $TODIR 1/$NAME 1              fi            ;;             d irectory)              read -p  " What is your backup to dir (absolute location): " TODIR2              read -p  "what is your  Backup name: " NAME2                if [ -e  $TODIR 2/$NAME 2 ];then                 read -p  "Do you want to change  name[yes/no]: " CHNAME2                 case  $CHNAME 2 in                     yes)                        read -p  "What is you change  names: " CHNAMES2                       mv  $TODIR 2/$NAME 2  $TODIR 2/$CHNAMES 2                        echo  "Change success"                        cp -r  $BACKUP   $TODIR 2/ name2                     ;;                      no)                      exit 2                     ;;                 esac                else                 mkdir  $TODIR 2                 cp -r  $BACKUP   $TODIR 2/name2                fi            ;; esacread -p  "do you want to change time by touch[yes/no]:"   touchcase  $TOUCH  in         yes)               touch  $BACKUP               echo  "Successfuly"          ;;          no)               echo  "Waring!next backup continue source file"           ;; Esac


Interactive Scripting example-data backup

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.