if![-d /backup ];then mkdir /backup;fi if[ 1 -ge $# ];then echo "Usage: $0 [full|inc] dir file ...";exit;fi for i in $SRCFILE;do if![-f $i ];then echo "Error: File \"$i\" is not exist, please input the right files!";exit;fi done
#================================ Backup Action =============================== case $1 in full) rm -f /tmp/.snapshot tar --wildcards --exclude *.log -g /tmp/.snapshot -zcPf $DSTFILE $SRCFILE ;; inc) tar --wildcards --exclude *.log -g /tmp/.snapshot -zcPf $BSTFILE $SRCFILE ;; *) echo "Usage: $0 [full|inc] dir file ...";exit ;; esac
#================================ Check Backup =============================== if[-f $DSTFILE ];then echo "Backup Sucsess!" echo "You have execut a $1 backup." echo "You are back \"$SRCFILE\" to $DSTFILE!" else echo "Error: Backup faild, pleas check it!" fi