linux下自动备份数据库

08 01 * * 0,3,5 /home/jiang/backup/autobackup.sh
 
autobackup.sh程序如下:
 
 
 
#!/bin/bash
############### System Backup to FTP ################
#Power By Jiang Daoyou
#E-mail:jiang_daoyou
cml.com.cn
#1. mkdir /home/jiang/backup
#2. chmod 700 autobackup.sh
#3. crontab -e
#System Setup
host="x.x.x.x" #ftp host
UserName=backupuser      #ftp user name
Passwd=password       #fto user password
backup_path="/home/jiang/backup"  #set saved backup path
time=`/bin/date |awk ''{print $6""$2""$3"_"$4}''|awk -F"_" ''{print $2}''|awk -F: ''{print $1""$2""$3}''`
file=webserver-$(date +%Y%m%d)$time.tar.gz

#################### backup  ########################
#stop mysql database server
#/usr/bin/killall mysqld
#/etc/rc.c/init.d/mysqld stop 对于备份mysql要做适当修改
#sleep 5s  #stop 5 second
#file tar
#tar -czf $backup_path/$file $backupfile
tar -czf $backup_path/$file  /etc /var/log/daemon /var/log/server.log /var/log/httpd /var/log/cmdlog
sleep 5s
#start mysql database server
#/usr/local/mysql/bin/mysqld_safe --user=mysql &  #set your mysqld path
#/etc/rc.d/init.d/mysqld start
cd $backup_path
sleep 2s
#file ftp
ftp -i -n <<!
open $host
user $UserName $Passwd
cd pptpserver
bin
mput  $file
bye
!
#sleep 10s
rm -rf $backup_path/$file 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值