当前位置:网站首页>Scheduled database backup script
Scheduled database backup script
2022-06-24 08:39:00 【An unreliable programmer】
Timing task
crontab Commands are used to set the instructions that are executed periodically . This command reads instructions from the standard input device , And store it in “crontab” In file , For later reading and execution .
Usually linux It's all built in crontab command . If not, please install by yourself .
file
crontab stay /etc Directory exists below cron.hourly,cron.daily,cron.weekly,cron.monthly,cron.d Five directories and crontab,cron.deny Two documents .
cron.daily It is executed once a day job
cron.weekly It is implemented once a week job
cron.monthly It is implemented once a month job
cron.hourly It is executed every hour job
cron.d It's a task that the system needs to do automatically and regularly
crontab Is to set a scheduled task execution file
cron.deny Files are used to control which users are not allowed to use Crontab The function of
Each user has its own cron The configuration file , adopt crontab -e You can edit , In general, we edit the user's cron Save the configuration file and exit , The system will automatically store it in /var/spool/cron/ Directory , The file is named after the user name .linux Of cron The service is to read every other minute /var/spool/cron,/etc/crontab,/etc/cron.d All the following .
Some orders
crontab –e : modify crontab file , If the file does not exist, it will be created automatically .
crontab –l : Show crontab file .
crontab -r : Delete crontab file .
crontab -ir : Delete crontab Remind user before file .
Database scheduled backup script xtrabackup.sh
#!/bin/bash
defaults_file="/etc/my.cnf" # mysql Profile location
user="backup" #mysql account number
password="backup" #mysql password
backup_dir="/path/to/backup/" # The root directory that needs to be archived
time_dir="$(date +"%Y%m%d%H%M%S")"
shell='innobackupex --defaults-file='$defaults_file' --user='$user' --password='$password' --stream=tar /temp | ssh [email protected] Remote machine "gzip -> '$backup_dir$time_dir'.tar.gz"'
eval $shellAdd scripts to scheduled tasks
- command
minute hour day month week command
branch when God month week command
perform crontab –e
00 02 * * * /bin/bash /path/to/xtrabackup.sh
边栏推荐
- Pyqt common system events
- 【微服务~Nacos】Nacos服务提供者和服务消费者
- Blue screen error UNMOUNTABLE boot volume of the solution
- Shell pass parameters
- 小黑ai4code代码baseline啃食1
- [xinliu-s6 new model +sa 3-star Xinghai] the new two-way server of the third generation chip was launched and the product was updated~
- Five level classification of loans
- ZUCC_编译语言原理与编译_实验01 语言分析与简介
- Question 3 - MessageBox pop-up box, modify the default background color
- Promise usage scenarios
猜你喜欢

js中通过key查找和更新对象中指定值的方法

ZUCC_编译语言原理与编译_实验03 编译器入门
![[explain the difference between operation and maintenance and network engineering]](/img/2b/945f468588e729336e2e973e777623.jpg)
[explain the difference between operation and maintenance and network engineering]

Permission model DAC ACL RBAC ABAC

ZUCC_ Principles of compiling language and compilation_ Experiment 01 language analysis and introduction

ZUCC_编译语言原理与编译_实验05 正则表达式、有限自动机、词法分析

Redis cluster data skew

日本大阪大学万伟伟研究员介绍基于WRS系统机器人的快速集成方法和应用

ZUCC_ Principles of compiling language and compilation_ Experiment 02 fsharp Ocaml language

ZUCC_编译语言原理与编译_实验02 FSharp OCaml语言
随机推荐
How to implement approval function in Tekton
Synthesize video through ffmpeg according to m3u8 file of video on the network
ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析
Shell basic operators -- relational operators
RCNN、Fast-RCNN、Faster-RCNN介绍
ZUCC_ Principles of compiling language and compilation_ Experiment 08 parsing LR parsing
JS scroll div scroll bar to bottom
Export MySQL database to xxx SQL, set xxx The SQL file is imported into MySQL on the server. Project deployment.
mysql组合索引的有序性
Five level classification of loans
Detailed explanation of etcd backup and recovery principle and actual record of stepping on the pit
Question bank and simulation examination for operation certificate of refrigeration and air conditioning equipment in 2022
ZUCC_编译语言原理与编译_实验03 编译器入门
Cloudbase database migration scheme
Markdown to realize text link jump
Rust procedure macro simply imitates Lombok function
ZUCC_ Principles of compiling language and compilation_ Big job
【力扣10天SQL入门】Day2
Video Fusion communication has become an inevitable trend of emergency command communication. How to realize it based on easyrtc?
利用ngrok做内网穿透