备份MySQL数据库到七牛云的shell脚本

#!/bin/sh

# database info
db_user="test"
db_pass="test"
db_host="test.mysql.rds.aliyuncs.com"
db_name="test"

# others vars
bin_dir="/usr/bin"            #the mysql bin path
backup_dir="/home/backup"    #the backup file directory
date=`date +%F`

file_name=$db_name"_"$date

# todo
$bin_dir/mysqldump  --set-gtid-purged=OFF --opt -u$db_user -p$db_pass -h$db_host  $db_name --ignore-table=adrms.security_access_log> $backup_dir/$file_name".sql"
cd $backup_dir
tar cvzfP  $file_name".tar.gz"  $file_name".sql"
mv  $file_name".tar.gz"  $db_name
rm -f  $backup_dir/$file_name".sql"

# upload to qiniu 

/home/backup/qshell  qupload 100  /home/backup/backup2qiniu.txt

 

{
"src_dir" : "/home/backup/adrms",
"access_key" : "access_key",
"secret_key" : "secret_key",
"bucket" : "bucket",
"zone" : "nb",
"rescan_local" : true,
"skip_path_prefixes" : ".qshell"
}

 

posted @ 2021-05-12 23:27  nanahome  阅读(91)  评论(0编辑  收藏  举报