各位,我目前的脚本是这样的:
[root@mysql1 /]# vi discuz.sh
#!/bin/sh
# File: mysqlautobak.sh
# Database info
DB_NAME="discuz"
DB_USER="root"
DB_PASS="123456"
# Others vars
BIN_DIR="/usr/bin"
BCK_DIR="/mysqlbak/"
DATE=`date +%Y%m%d_%H:%M:%S`
# TODO
$BIN_DIR/mysqldump --opt -u$DB_USER -p$DB_PASS $DB_NAME | gzip > $BCK_DIR/Discuz$DATE.gz
自动FTP 方式
- ftp -i -n 192.168.1.23 << MY_FTP
- user anonymous clb@localhost
- binary
- put $BCK_DIR/Discuz$DATE.gz
- quit
- MY_FTP
复制代码自动删除5天前
find $BCK_DIR -mtime +5 | xargs rm -rf
阅读(1234) | 评论(0) | 转发(0) |