您的位置:首页 > 运维架构 > Shell

shell备份目录脚本

2016-06-23 23:27 337 查看
#需求
写一个备份脚本,用来备份samba文件 保留20天
#!/bin/bash
dir="/samba/operations"
backup="/data"
filename="operations.tar.bzip2"
date=`date +%Y%m%d`
[ ! -e "$dir" ] && echo "请联系管理员" && exit
[ ! -e "$backup" ] && mkdir $backup
/bin/mkdir $backup/$date
/bin/tar jcvf  $backup/$date/$filename  $dir/
find "$backup" -type d -mtime +20 -exec rm {} \;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell 备份脚本