Linux系统下的文件自动备份到Windows下
若/dev/hda1为windows下的fat32分区,则mkdir /mnt/win_c, /var/www为你要备份的目录
写如下脚本,保存为/root/backup_var_www.sh,加上执行权限。
#!/bin/bash if ! grep -q '/dev/hda1' /proc/mounts then mount /dev/hda1 /mnt/win_c || exit fi backup_ball="/mnt/win_c/var_www_$(date +%F).tar.bz2" if tar jcf $backup_ball /var/www then echo "$backup_ball backup succeeded. :)" | mail -s "backup OK" root else echo "$backup_ball backup failed. :(" | mail -s "backup FAILED" root fi
然后crontab -e
加入
30 4 * * 5 /bin/bash /root/backup_var_www.sh
即在每周五的4:30分执行备份操作。
顶(0)
踩(0)
- 最新评论