Interactive Scripting Example (2)-Data backup

Source: Internet
Author: User

#!/bin/bashread -p  "Input the source file or directory you want  to backup (Absolute path):  " sourif [ ! -e  $sour  ];  then   echo  "The source file or directory not exits.the  script is end. "      exit 1firead -p  "Input the targe filename or  directoryname (Absolut path):  " tarif [ -e  $tar  ]; then    echo  "The target is exits"    read -p  "do you  need to rename? (yes|no) " yn   case  $yn  in   yes|y)           read -p  "Input the new name (absolut path): "   newname         mv  $tar   $newname          cp -r  $sour   $tar           echo  "Backup success"  ;;    no|n)          if [ -d  $tar   ]; then            cp -r  $sour   $tar             echo  "backup  Success "         else             echo  "Can not backup"              exit 2         fi          ;;    esacelse   tdir= ' dirname  $tar '    mkdir -r  $tdir  &> /dev/null   cp -r  $sour   $tar    echo  "backup  Success "fi


Interactive Scripting Example (2)-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.