脚本内容:1234567891011121314151617181920#!/bin/bash# 博客目录blog_dir="/data/hexo/blog"# 备份目录backup_dir="/data/backup/hexo"# 备份文件名格式backup_filename=$(date +%Y%m%d_%H%M%S)# 备份echo "开始备份博客..."tar -czvf ${backup_dir}/${backup_filename}.tar.gz ${blog_dir}echo "备份成功"# 删除7天前的备份echo "删除7天前的备份..."find ${backup_dir} -type f -mtime +7 -exec rm -rf {} \;echo "删除成功" 定时执行12# 每晚2点执行一次0 2 * * * /bin/bash /path/to/backup.sh