当前位置:网站首页>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 {
}

边栏推荐
- (2022牛客多校三)J-Journey(dijkstra)
- 在rhel7.3中编译和使用log4cxx
- 使用sqlplus显示中文为乱码的解决办法
- Chapter 6 Shell Logic and Arithmetic
- 海康h9摄像头用xshell无法连接(没有启用ssh)
- Usage of string class
- 次轮Okaleido Tiger即将登录Binance NFT,引发社区热议
- ? Experiment 7 implementation of PHP management system based on MySQL
- ADB instruction sorting
- Zabbix: map collected values to readable statements
猜你喜欢

Use the PIP command to switch between different mirror sources

Generics -- learn it, and there are many benefits

(2022杭电多校三)1009.Package Delivery(贪心)

在kettle使用循环来处理表中的数据

【QT】capture.obj:-1: error: LNK2019: 无法解析的外部符号 __imp_htons(解决方法)

Which C4d cloud rendering platform to cooperate with?

Essay: college entrance examination

Bash: create a function that returns a Boolean value

Tcp/ip protocol analysis (tcp/ip three handshakes & four waves + OSI & TCP / IP model)
![[wsl2] configure the USB camera connecting the USB device and using the host](/img/03/7ebc7eebeda1598c8f4fdd1e9188c7.png)
[wsl2] configure the USB camera connecting the USB device and using the host
随机推荐
Demonstrate the use of foreign keys with Oracle
漏风的小棉袄……
在mysql中同时使用left join on 和where 的查询结果分析
Binary tree -- natural search semantics (1) Basics
简单的轮播图
TCP/IP协议分析(TCP/IP三次握手&四次挥手+OSI&TCP/IP模型)
Introduction to network -- overview of VLAN and trunk
flink去重(二)解决flink、flink-sql去重过程中的热点问题
View the dmesg log before server restart
No.0 training platform course-2. SSRF Foundation
flink去重(一)flink、flink-sql中常见的去重方案总结
闭散列和开散列解决哈希冲突
flink中维表Join几种常见方式总结
[Vani has a date] tail on rainy days
Single arm routing (explanation + experiment)
MySQL2
在rhel8上使用soci连接oracle和postgresql和sqlite
如何取得对象的DDL信息
Array method and loop in JS
Haikang H9 camera cannot be connected with xshell (SSH is not enabled)