In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Write a script to make automatic full and incremental backups
Full backup
Vim / rootspur allbak.shrootspur day= / backup/ / create a new folder dedicated to backup files day= `date +% F` / / the defined date is the time user=rootpass=123456innobackupex-- user $user-- password $date / backup/allbak$ {day}-no-timestamp / / make a full backup with innobackupex mysql-u$user-p$pass-e "flush logs" ``/ / enable binlog logs, after each 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 systemctl enable crond at 4: 00 a.m. from Tuesday to Sunday
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.