In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The following mainly brings you backup mysql through innobackup combined with planned tasks. I hope these contents can bring you practical use, which is also the main purpose of my editor to achieve backup mysql through innobackup combined with scheduled tasks. All right, don't talk too much nonsense, let's just read the following.
Write a script to make automatic full and incremental backups
Full backup
Refresh the binlog log
Vim / root/newbak.sh
#! / bin/bash
D1=date +% F / / defines the time, distinguished by date
D2=date +% F-d "- 1 days" / / find yesterday's date to indicate the backup file from the last backup
Dir1=/backup/allbak$ {d2} / / full backup files made yesterday
Dir2=/backup/newbak$ {D2} / / incremental backup files made yesterday
User=root
Pass=123456
[!-e / backup] & & mkdir / backup / / create a folder if the file does not exist
If [- e ${dir1}]; then / / judged that what was done yesterday was a full backup
Innobackupex-- user $user-- password $pass-- incremental / backup/newbak$ {D1}-- incremental-basedir=$ {dir1}-- no-timestamp / / specifies the full backup file that was backed up yesterday
Elif [- e ${dir2}]; then / / judged that what was done yesterday was an incremental backup
Innobackupex-- user $user-- password $pass-- incremental / backup/newbak$ {D1}-- incremental-basedir=$ {dir2}-- no-timestamp / / specify the incremental backup files backed up yesterday
Else
Innobackupex-user $user-password $pass / backup/allbak$ {D1}-no-timestamp
/ / if there was neither incremental backup nor full backup yesterday, do a full backup.
Fi
Add permission: chmod + x / root/allbak.sh chmod + x / root/newbak.sh write schedule task: crontab-e 00 03 * * 1 / root/allbak.sh & > / dev/null / / perform a full backup 00 04 * * 2-7 / root/newbak.sh & > / dev/null / / perform an incremental backup to restart the crond service systemctl restart crond at 4: 00 a.m. from Tuesday to Sunday
Systemctl enable crond
For the above about the combination of innobackup with scheduled tasks to achieve backup mysql, we do not think it is very helpful. If you need to know more, please continue to follow our industry information. I'm sure you'll like it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.