#!/bin/bash
Date=`date +%m%d%y -d "-1 days"`
mkdir /history/aa/$Date
touch /log/aa/$Date.log
echo "aa backup begin at `date +%H:%M:%S`" >> /log/aa/$Date.log
find /backup/aa/ -type f -mtime 1 -exec cp -rv {} /history/aa/$Date/ \;
echo "aa backup end at `date +%H:%M:%S`" >> /log/aa/$Date.log
find /history/aa/ -type d -mtime 1 -empty -exec rmdir {} \;
/usr/bin/mail -s "aa backup done" aa@ming.com </log/aa/$Date.log
不足:脚本需在0:00执行,否则24小时不能代表完整一天
本文出自 “linux” 博客,谢绝转载!
备份前一天(确切说是24小时前)数据的脚本,布布扣,bubuko.com
原文:http://yangzhiming.blog.51cto.com/4849999/1369867