当前位置:网站首页>MySQL backup strategy
MySQL backup strategy
2022-07-27 07:31:00 【Development, operation and maintenance Xuande public】
List of articles
1. Strategy
- Library to back up
iot and analytics library
- Daily backup
Every day 23:00 Back up once
- Hourly temporary backup
Backup temporarily every hour , Delete the backup before one day every morning
2. operation
2.1 Document preparation
dataPrepare under the directorymysql_dumpCatalog , For backupdata/mysql_dumpUnder the table of contents establishhour_tmpThe directory stores daily temporary backup filesdata/mysql_dumpUnder the table of contents establishmysql_dump.shScript ( Backup scripts )
2.2 Backup scripts
#!/bin/bash
##### Defining variables #######
date_now=`date +%Y%m%d%H%M`
dump_dir=$1
mysql_user="root"
mysql_ip="127.0.0.1"
mysql_port=3306
mysql_passwd="[email protected]"
####### Define the library to be backed up #################
# The database names to be backed up are one by one
back_dbs=(
iot
analytics
)
####### Start backup ##########
cd ${dump_dir}
### Backup each library ##
for back_db in ${back_dbs[@]};
do
mysqldump -h${mysql_ip} -P${mysql_port} -u${mysql_user} -p${mysql_passwd} -l -F ${back_db} > ./${back_db}.sql
tar czf ${back_db}-${date_now}.tar.gz ${back_db}.sql --remove-files
done
2.3 Timing task
Strategy :
1) Daily backup to/data/mysql_dump, Retain 15 God
2) Backup to every hour/data/mysql_dump/hour_tmp, Empty every morning
###########################
# mysql Backup related #
###########################
# Hourly temporary backup
30 * * * * /bin/bash /data/mysql_dump/mysql_dump.sh /data/mysql_dump/hour_tmp > /dev/null 2&>1
# Daily backup
00 23 * * * /bin/bash /data/mysql_dump/mysql_dump.sh /data/mysql_dump > /dev/null 2&>1
# Delete files temporarily backed up by hour every day
10 01 * * * /bin/find /data/mysql_dump/hour_tmp -name \*.tar.gz -mtime +1| xargs -I {
} rm -rf {
}
# Retain 15 Day backup
05 01 * * * /bin/find /data/mysql_dump -maxdepth 1 -name \*.tar.gz -mtime +15| xargs -I {
} rm -rf {
}

边栏推荐
- Jmeter: interface automation test - BeanShell compares database data and return data
- MySQL: 提高最大连接数
- View the dmesg log before server restart
- 杂谈:高考
- Actual combat of flutter - Request encapsulation (I)
- drawImage方法第一次调用不显示图片的解决方式
- The solution of using sqlplus to display Chinese as garbled code
- 基于Arduino的温度、湿度测量显示装置
- Array method and loop in JS
- DRConv-pytorch改称输出和输入一样的尺寸
猜你喜欢
随机推荐
Excuse me, MySQL timestamp (6) using flick SQL is null. Is there a way to deal with this
【golang学习笔记2.0】 golang中的数组和切片
centos7中关闭oracle服务自动启动的功能
Please ask the big guys a question. The pgsqlcdc task can't monitor changes after running for a period of time. Just restart it. What should I do
flink中维表Join几种常见方式总结
flink1.14 sql基础语法(一) flink sql表查询详解
How to submit C4d animation to cloud rendering farm for fast rendering?
Simple rotation chart
利用 Amazon DynamoDB 和 Amazon S3 结合 gzip 压缩,最大化存储玩家数据
Perl: split the external command to be executed into multiple lines
在rhel7.3中编译和使用log4cxx
JS make a traffic light
Basic functions and collections of guava
Graylog 日志服务器单节点部署
TCP/IP协议分析(TCP/IP三次握手&四次挥手+OSI&TCP/IP模型)
在mysql中同时使用left join on 和where 的查询结果分析
Oracle composite query
单元测试系统化讲解之Mockito
Will Flink CDC constantly occupy Oracle's memory by extracting Oracle's data, and finally cause oracle-040
用oracle来演示外键的使用









