🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
```shell #!/bin/sh #Author:BrandynX #Date:2017-03-27 #Remark: File bakcup to NFS #Declare the time variable NFS_SAVEDAYS="7" LOCAL_SAVEDAYS="1" TODAY=`date +%Y%m%d` LOCAL_BACKUPDIR_DAY=`date -d "-$LOCAL_SAVEDAYS days" +%Y%m%d` NFS_BACKUPDIR_DAY=`date -d "-$NFS_SAVEDAYS days " +%Y%m%d` LOCAL_DIR=/data/backup REMORT_DIR=/nfsdir/bois BOIS_DIR=/data/bois MONITOR_DIR=/usr/share/monitor MSHOW_DIR=/usr/share/monitorshow LOG_DIR=/app/scripts APACHE_DIR=/etc/httpd LOGSERVER_DIR=/data/syslogserver #Loacl backup file processing #Create today bakcupdir and backup if [ ! -d $TODAY ];then mkdir -p $LOCAL_DIR/$TODAY #copy the file to local backupdir cp -a $BOIS_DIR $LOCAL_DIR/$TODAY cp -a $MONITOR_DIR $LOCAL_DIR/$TODAY cp -a $MSHOW_DIR $LOCAL_DIR/$TODAY cp -a $APACHE_DIR $LOCAL_DIR/$TODAY cp -a $LOGSERVER_DIR $LOCAL_DIR/$TODAY cd $LOCAL_DIR tar czf $LOCAL_DIR/$TODAY-bois.tar.gz $TODAY echo "Bois $TODAY local bakcup is complete." >>$LOG_DIR/scripts.log fi #Synchornize file to NFS #To determine whether there is a bakcup if [ -f $REMORT_DIR/$TODAY-bois.tar.gz ];then echo "NFS already exists in $TODAY backup file." exit else cp $LOCAL_DIR/$TODAY-bois.tar.gz $REMORT_DIR echo "Bois $TODAY nfs bakcup is complete." >>$LOG_DIR/scripts.log fi #Delete local backup if [ -d $LOCAL_DIR/$LOCAL_BACKUPDIR_DAY ];then rm -rf $LOCAL_DIR/$LOCAL_BACKUPDIR_DAY rm -f $LOCAL_DIR/$LOCAL_BACKUPDIR_DAY-bois.tar.gz echo "Bois $LOCAL_BACKUPDIR_DAY locat backup is delete. " >> $LOG_DIR/scripts.log fi #Delete nfs backup rm -f $REMORT_DIR/$NFS_BACKUPDIR_DAY-bois.tar.gz echo "Bois $NFS_BACKUPDIR_DAY nfs backup is delete. " >> $LOG_DIR/scripts.log ```