客户要备份一些数据,有两种选择,使用bacula(一种免费的开源软件)或者脚本,我选择用脚本备份,公司有个很复杂的备份脚本,以前研究过,隔了好长时间,所以昨天有仔细的看了一遍,测试了一下,可以正常把数据备份到S3上面去,今天抽空把里面一些不太清楚的地方特意拿出来跑一下

[root@localhost ~]# cat 1.sh 

#!/bin/bash

OPTIONS=`getopt --options hvitrc: --long help,version,init,test,run,config: -- "$@"`

if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi

eval set -- "$OPTIONS"

while true ; do

  case "$1" in

    -h|--help) ecoh help ; exit ;;

    -v|--version) echo print_version ; exit ;;

    -i|--init) echo init_script_flag ; shift ;; # NOT IN USE YET

    -t|--test) echo test_flag=1 ; shift ;;

    -r|--run) echo run_flag ; shift ;;

    -c|--config) CONF_FILE=$2 echo $CONF_FILE ; shift 2 ;;

    --) shift ; break ;;

    *) echo "Internal error!" ; exit 1 ;;

  esac

done