日自动备份本服务器数据,打包压缩上传到七牛云参考脚本
1 #!/bin/sh 2 3 # database info 4 db_user="AAA" 5 db_pass="111111111111" 6 db_host="127.0.0.1" 7 db_name="AAA" 8 9 # others vars 10 bin_dir="/usr/bin" #the mysql bin path 11 backup_dir="/home/backup" #the backup file directory 12 date=`date +%F` 13 14 file_name=$db_name"_"$date 15 16 # todo 17 $bin_dir/mysqldump --set-gtid-purged=OFF --opt -u$db_user -p$db_pass -h$db_host $db_name --ignore-table=$db_name.security_access_log > $backup_dir/$file_name".sql" 18 cd $backup_dir 19 tar cvzfP $file_name".tar.gz" $file_name".sql" 20 mv $file_name".tar.gz" $db_name 21 rm -f $backup_dir/$file_name".sql" 22 23 # upload to qiniu 24 /home/backup/qshell qupload ./qshellconf.json
qshell 是七牛的程序