首页 > 系统 > Linux > 正文

备份shell脚本实例代码

2019-10-26 18:35:58
字体:
来源:转载
供稿:网友
1、backup_run.sh
代码如下:
    #!/bin/sh
    # backup_run
    # script to run the backups
    # loads in a setting file for the user to change
    SOURCE=/home/bob/backup.defaults
    check_source()
    {
        # check_source
        # can we load the file
        # backup.defaults is the source file containing config/functions
        # make sure your path includes this directory you are runing from
        if [ -r $SOURCE ];then
          . $SOURCE # load $source
        else
            echo "`basename $0`: cannot locate default file"
            exit 1
        fi
    }
    header()
    {
        # header
        USER=`whoami`
        MYDATE=`date +%A" "%e" of "%B-%Y`
        clear
        cat << HH
        User: $USER $MYDATE
                    NETWORK SYSTEM BACKUP
                    =====================
    HH
    }
    change_settings()
    {
        # change_settings
        # let the user see the default settings..
        header
        echo "Valid Entries Are..."
        echo "Tape Device: rmt0,rmt1,rmt3"
        echo "Mail Admin:yes,no"
        echo "Backup Type: full,normal,sybase "
        while :
        do
            echo -n -c "/n/n Tape Device To Be Used For This Backup [$_DEVICE] :"
            read T_DEVICE
            : ${T_DEVICE:=$_DEVICE}
            case $T_DEVICE in
                rmt0|rmt1|rmt3) break
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表