当前位置:网站首页>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
边栏推荐
- 【关于运维和网工的差别,一文说透】
- LabVIEW finds prime numbers in an array of n elements
- How to improve the customer retention rate in the operation of independent stations? Customer segmentation is very important!
- ZUCC_编译语言原理与编译_实验04 语言与文法
- 【微服务~Nacos】Nacos服务提供者和服务消费者
- IIS build wordpress5.7 manually
- Cloudbase database migration scheme
- [micro services ~nacos] Nacos service providers and service consumers
- ZUCC_ Principles of compiling language and compilation_ Experiment 03 getting started with compiler
- How to mount a USB hard disk with NTFS file format under RHEL5 system
猜你喜欢

jwt(json web token)

Longhorn installation and use

JUC personal simple notes

Question 4 - datepicker date selector, disabling two date selectors (start and end dates)

MATLAB Camera Calibrator相机标定

Redis cluster data skew

2021-03-09 comp9021 class 7 Notes

ZUCC_ Principles of compiling language and compilation_ Experiment 08 parsing LR parsing

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

成为IEEE学生会员
随机推荐
05 Ubuntu installing mysql8
Why do you want to file? What are the advantages and disadvantages of website filing?
JS to get the last element of the array
Tencent cloud ASR product PHP realizes real-time voice authentication request
Review SGI STL secondary space configurator (internal storage pool) | notes for personal use
JS merge multiple objects and remove duplicates
ZUCC_ Principles of compiling language and compilation_ Experiment 03 getting started with compiler
Battle history between redis and me under billion level traffic
利用ngrok做内网穿透
[graduation season] Hello stranger, this is a pink letter
【无标题】
Common date formatter and QT method for obtaining current time
图片工具
[explain the difference between operation and maintenance and network engineering]
中国芯片独角兽公司
数据平台简介
ZUCC_ Principles of compiling language and compilation_ Experiment 08 parsing LR parsing
uniapp 热更新后台管理
12-- merge two ordered linked lists
Permission model DAC ACL RBAC ABAC