- [root@localhost bin]# vi smgpSendWriteFile_file_bak.sh
- #!/bin/sh
- dirname="$(date +%Y%m%d)"
- a=/usr/local/copydata/smgpSendWriteFile/
- b="smgpSendWriteFile_"$dirname
- c=$a$b
- d="/var/log/filecopy/smgpSendWriteFile/smgpSendWriteFile_tar_"$dirname".log"
- e="/var/log/filecopy/smgpSendWriteFile/"
- mkdir -p $a
- mkdir -p $e
- #改名
- cd /usr/local/smgpSend
- mv smgpSendWriteFile $c
- #重建
- /backup/bin/smgpSendWriteFile_file_mk.sh
- #压缩
- cd $a
- tar -zcvf smgpSendWriteFile_$dirname.tar.gz smgpSendWriteFile_$dirname >> $d
- #删除
- rm -rvf smgpSendWriteFile_$dirname >> $d
建立文件夹脚本
- [root@localhost bin]# vi smgpSendWriteFile_file_mk.sh
- #!/bin/sh
- mkdir /usr/local/smgpSend/smgpSendWriteFile
- cd /usr/local/smgpSend/smgpSendWriteFile
- mkdir file_info_deliver
- mkdir file_info_deliverDisposed
- mkdir file_info_map
- mkdir file_info_mapDisposed
- mkdir file_info_report
- mkdir file_info_reportDisposed
- mkdir file_info_send
- mkdir file_info_sendDisposed
- mkdir file_info_send_match
- mkdir smgpSms
- mkdir smgpSmsDisposed
==============下面是个备份,是以前写的,不够灵活==================
- #!/bin/sh
- dirname="$(date +%Y%m%d)"
- #改名
- cd /usr/local/smgpSend
- mv smgpSendWriteFile /usr/local/copydata/smgpSendWriteFile/smgpSendWriteFile_$dirname
- #重建
- /backup/bin/smgpSendWriteFile_file_mk.sh
- #压缩
- cd /usr/local/copydata/smgpSendWriteFile
- tar -zcvf smgpSendWriteFile_$dirname.tar.gz smgpSendWriteFile_$dirname >> /var/log/filecopy/smgpSendWriteFile/smgpSendWriteFile_tar_$dirname
- #删除
- rm -rvf smgpSendWriteFile_$dirname >> /var/log/filecopy/smgpSendWriteFile/smgpSendWriteFile_rm_$dirname