#需求
写一个备份脚本,用来备份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 {} \;