当前位置:网站首页>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
边栏推荐
- leetcode 1642. Furthest Building You Can Reach(能到达的最远的建筑)
- 定时备份数据库脚本
- Promise的使用场景
- List of Li Bai's 20 most classic poems
- Common date formatter and QT method for obtaining current time
- ZUCC_编译语言原理与编译_大作业
- MATLAB Camera Calibrator相机标定
- 【力扣10天SQL入门】Day3
- 2021-03-04 comp9021 class 6 notes
- Easydss anonymous live channel data volume instability optimization scheme sharing
猜你喜欢

jwt(json web token)

5 minutes, excellent customer service chat handling skills

uniapp 热更新后台管理

The article takes you to understand the security of Windows operating system and protect your computer from infringement

【无标题】

Maya re deployment

New technology practice, encapsulating the permission application library step by step with the activity results API

【微服务~Nacos】Nacos服务提供者和服务消费者

5分钟,客服聊天处理技巧,炉火纯青

2022 tea artist (intermediate) work license question bank and online simulation examination
随机推荐
AUTO PWN
leetcode 1642. Furthest Building You Can Reach(能到达的最远的建筑)
[acnoi2022] not a structure, more like a structure
PHP代码加密的几种方案
Two methods of QT exporting PDF files
常用日期格式符与Qt获取当前时间的办法
Qt源码分析--QObject(2)
lombok 使用
ZUCC_编译语言原理与编译_实验06 07 语法分析 LL 分析
Common CVM transcribes audio using virtual sound card
The article takes you to understand the security of Windows operating system and protect your computer from infringement
After interviewing and tutoring several children, I found some problems!
Fundamentals of 3D mathematics [17] inverse square theorem
DHCP, TFTP Foundation
JUC personal simple notes
Final review and key points of software process and project management
Which is the first poem of Tang Dynasty?
Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
QT writing security video monitoring system 36 onvif continuous movement
Shell basic operator -- arithmetic operator