aliyun auto mysql and file backup to oss

//autorun

crontab -e

02 4 * * * root run-parts /etc/cron.daily
42 4 1 * * root run-parts /etc/cron.monthly
// mysqlbackup 

vi  /etc/cron.daily/bakmysql.sh


DATE=`date +%Y%m%d%H%M` #every minute
DATABASE=wordpress_hss5com #database name
DB_USER=wordpress #database username
DB_PASS="wordpress" #database password
BACKUP=/data/dbbackup #backup path

#backup command

/usr/bin/mysqldump -u$DB_USER -p$DB_PASS -h 127.0.0.1 -R --opt $DATABASE |gzip > ${BACKUP}\/${DATABASE}_${DATE}.sql.gz

# send to oss 

/var/local/src/ossutil64 cp /data/dbbackup/ oss://vpseo.com/dbbackup -r -u



#just backup the latest 5 days

find ${BACKUP} -name "${DATABASE}_*.sql.gz" -type f -mtime +50 -exec rm {} \; > /dev/null 2>&1

 

vi  /etc/cron.monthly/bakfile.sh

// file backup

DATE=`date +%Y%m%d%H%M` #every minute

WEBSITE=hss5com

BACKUP=/data/filebackup #backup path

#backup command

zip -r ${BACKUP}\/${WEBSITE}_${DATE}_file.zip /var/www/html/*
#zip -r ${BACKUP}\/host2.${WEBSITE}_${DATE}_file.zip /var/www/html/host2/*

/var/local/src/ossutil64 cp /data/filebackup/ oss://hss5com/filebackup -r -u

#just backup the latest 365 days

find ${BACKUP} -name "${WEBSITE}_*.zip" -type f -mtime +365 -exec rm {} \; > /dev/null 2>&1


 

mysql 每日自动备份, 文件每月自动备份 到 阿里云oss

config ossutil64 tool for oss upload/download

http://vpseo.com/2019/03/04/aliyun-oss-ossutil-tool/

 

相关推荐

aliyun oss file batch upload shell command

摘要: 经常碰到内部同学或者外部客户问ossutil关于增量上传的问题。本文简单描述下原理并举例说明。 # 应用场景 ## 场景一 某用户有一批文件(比如1000个)要上传到OSS(或从OSS下载,或从OSS拷贝到OSS,下同),当执行批量上传的过程中出现失败(比如在上传第601个文件时失败)。

暂无评论

微信扫一扫,分享到朋友圈

aliyun auto mysql and file backup to oss