执行的时候在脚本后面加上应用的名字,比如我想备份gcmis,就执行
./bak.sh gcmis
脚本详细内容
#!/bin/bash
# This Script for Bukcup ZMMIS APP
# by Zhang Yong Chao & Cheng Meng
# Backup List:cas etl etliems fmis gcmap gcmis gcpw gpw hos mdm panetl portal
BK_DATE=$(date +'%Y%m%d%H%M')
a=$1
b=/u01/app/zmmis
c="/backup/zmmis/$1"
cd $b
if [ "$a==gcmis" -o "$a==Iems" -o "$a==cas" ]; then
tar zcvf $c/$1_$BK_DATE.tar.gz $b/$1/ --exclude *.log
echo -e "\033[32m "$1备份成功!请转至/backup/zmmis/$1查看备份情况"\033[0m"
elif [ "$a==gcpw" -o "$a==gpw" ]; then
tar tar zcvf $c/$1_$BK_DATE.tar.gz $b/$1/$1/ --exclude *.log
echo -e "\033[32m "$1备份成功!请转至/backup/zmmis/$1查看备份情况"\033[0m"
elif [ "$a==EtlIems" -o "$a==fmis" -o "$a==gcmap" ]; then
tar zcvf $c/$1_$BK_DATE.tar.gz $b/$1/ --exclude *.log
echo -e "\033[32m "$1备份成功!请转至/backup/zmmis/$1查看备份情况"\033[0m"
elif [ "$a==hos" -o "$a==mdm" -o "$a==panetl" -o "$a=portal"]; then
tar zcvf $c/$1_$BK_DATE.tar.gz $b/$1/ --exclude *.log
echo -e "\033[32m "$1备份成功!请转至/backup/zmmis/$1查看备份情况"\033[0m"
else
echo -e "\033[31m $1备份失败,请在脚本后输入需要备份的程序名字,比如filebak.sh gcpw\033[0m"