注:/backfiles是需要备份的文件目录,192.168.0.2是ftp,我们每天晚上1点将需要备份的数据写到ftp服务器上。
使用crond实现文件shell的自动执行:
/var/spool/cron/root
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.28843 installed on Fri Nov 14 15:53:05 2003)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
0 1 * * * sh /backflies/backup.sh #每天晚上一点执行备份shell
/backfiles/backup.sh
#! /bin/bash
Times=`date "+%Y%m%d"`
# delete old backup files
/bin/rm -rf /backfiles/backfiles*.tar.gz
# files backup
tar -czvf /backfiles/backfiles$Times.tar.gz /backfiles
# second media back up
ftp -i 192.168.0.2
/root/.netrc
machine 192.168.0.2 login ftp_username password ftp_passwd macdef init
binary
lcd /backfiles
mput *.tar.gz
quit
[这里有一个空行]
阅读(327) | 评论(0) | 转发(0) |