Create backup directory

cd /home
mkdir backup
cd backup

Create a backup Shell Script :

vim DatabaseName.sh
#!/bin/bash
/usr/local/mysql/bin/mysqldump -uusername -ppassword DatabaseName > /home/backup/DatabaseName_$(date +%Y%m%d_%H%M%S).sql Compress the backup : #!/bin/bash
/usr/local/mysql/bin/mysqldump -uusername -ppassword DatabaseName | gzip > /home/backup/DatabaseName_$(date +%Y%m%d_%H%M%S).sql.gz Be careful :
hold username Replace with the actual user name ;
hold password Replace with the actual password ;
hold DatabaseName Replace with the actual database name ;

Add executable rights

chmod u+x DatabaseName.sh

Add scheduled tasks

crontab -e
01 3 * * * root/home/backup/DatabaseName.sh Means every day 3 I'm going to perform a backup

Crontab The format of

 The first 1 One minute 1~59
The first 2 Train hours 1~23(0 Midnight )
The first 3 Liege, 1~31
The first 4 Column month 1~12
The first 5 It's a week 0~6(0 Sunday )
The first 6 Column command to run Here is crontab The format of :
branch when Japan month week Commands to run Here you are crontab Some examples of file entries : 30 21 * * * /usr/local/apache/bin/apachectl restart
The example above shows that every night 21:30 restart apache. 45 4 1,10,22 * * /usr/local/apache/bin/apachectl restart
The above example shows monthly 1、10、22 Japanese 4 : 45 restart apache. 10 1 * * 6,0 /usr/local/apache/bin/apachectl restart
The above example shows every Saturday 、 Sunday's 1 : 10 restart apache. 0,30 18-23 * * * /usr/local/apache/bin/apachectl restart
The above example shows that every day 18 : 00 to 23 : 00 Between every 30 Minutes to restart apache. 0 23 * * 6 /usr/local/apache/bin/apachectl restart
The above example shows that every Saturday 11 : 00 pm restart apache. 0 */1 * * * /usr/local/apache/bin/apachectl restart
Restart every hour apache #20160912 correct , thank @ Zhang Qiong's correction , I made a mistake ,*/1 and * It means the same thing , about / Usage of , You can refer to another article Crontab How to use the division sign in ? 0 23-7/1 * * * /usr/local/apache/bin/apachectl restart
evening 11 Point to morning 7 Between points , Restart every hour apache 0 11 4 * mon-wed /usr/local/apache/bin/apachectl restart
Monthly 4 Day and Monday to Wednesday every week 11 Click restart apache 0 4 1 jan * /usr/local/apache/bin/apachectl restart
On January 1st 4 Click restart apache

Reference link :https://mp.weixin.qq.com/s?__biz=MzA3OTgyMDcwNg==&mid=2650631459&idx=1&sn=63479c55ea99b9db09e40696373721c4&chksm=87a46feeb0d3e6f8c3562a314c962760a52c5064599791fa00976f21a91348724854325a1a5d&mpshare=1&scene=23&srcid=0823Ts1Ic9kGVSPzTLjLPPUR#rd

MySQL More related articles about automatic database backup

  1. MySQL Database automatic backup script on a regular basis

    Web System , The most important thing is the security and integrity of the database .    Backup regularly , It's very important , Don't be lazy on this issue . If your important data is lost , Will make you want to cry without tears . Export table structure and data mysqldump -uroot ...

  2. linux How to realize mysql The database is automatically backed up regularly

    summary Backup is the foundation of disaster recovery , In order to prevent data loss caused by system operation error or system failure , The process of copying all or part of the data set from the application host's hard disk or array to other storage media . And for some sites . system , Database is everything , So do a good job ...

  3. Mysql How to back up the database automatically

    Mysql How to back up the database automatically One . summary One sentence summary : use navicat coordination windows Batch processing of navicat windows The batch Two .Mysql Automatic database backup Reference resources :Mysql Automatic database backup ...

  4. SQL Server The database is automatically backed up regularly

    SQL Server The database is automatically backed up regularly [ turn ]   stay SQL Server For the sake of data security , So you need to back up the database regularly . And the backup database is generally in the early morning when there is no database operation , So we can't ask for ...

  5. SQL Server The database is automatically backed up regularly

    original text :SQL Server The database is automatically backed up regularly SQL Server The database is automatically backed up regularly —— Back up regularly every day , Leave the 8 Days of backup utilize SQL Server The agent creates a new job to back up periodically 1) In the database [SQL S ...

  6. ( backstage )SQL Server The database is automatically backed up regularly ( turn )

    From blog Park : SQL Server The database is automatically backed up regularly [ turn ]   stay SQL Server For the sake of data security , So you need to back up the database regularly . And the backup database is generally in the early morning when there is no database operation , therefore ...

  7. Sqlserver The database is automatically backed up regularly

    sqlserver Through Microsoft tools  SQL Server Management Studio   Automatic and regular backup of database , The specific steps are as follows : 1, open SQL Server Management Studi ...

  8. Linux achieve mysql The database is automatically backed up every day

    Linux achieve mysql The database is automatically backed up every day 1. Basic operation steps a. Create backup directory mkdir -m 777 /home/wwwroot/backup b. Create a backup script sh vim /home/wwwr ...

  9. [ Reprint ]SQL Server The database is automatically backed up regularly

    Recommended SQLserver Self contained SSMS Tool to create a maintenance plan to achieve automatic database backup “ Maintenance plan ” Is in SSMS Object resource management “ management ” Below the node . Maintenance plan can be used through visual operation , You can create a database with just a click of the mouse ...

Random recommendation

  1. On the picture load a very cool tripartite control fresco, A three fresco

    Hi  EveryBody Let's play a very cool control today fresco How cool is it Then I can see First Let's see fresco It's a magic horse thing https://github.com/facebook/fre ...

  2. Joda-Time

    Any enterprise application needs to deal with time issues . The application needs to know the current point in time and the next point in time , Sometimes they also have to calculate the path between these two points in time . Use JDK It's going to be very painful and tedious to complete this task . Now let's see Joda Time, One ...

  3. Oracle The cursor Cursor The basic usage of

    Inquire about SELECT Statement is used to query data from a database , When in PL/SQL Use in SELECT When the sentence is , To work with INTO Clauses are used together , Of the query The return value is given INTO Variable in clause , The declaration of a variable is in the DELCARE in .SELECT ...

  4. vue utilize mockJs Analog data

    I've been working for years Java Development , I forgot about the front-end technology ( Actually, I don't know how to ), The most recent project I participated in is using VUE +  Element-ui + springboot Written , Because the demand is uncertain , Draw a picture first de ...

  5. C++——list in erase and remove The difference between

    1. Before doing the relevant operation , It's about cleaning up list Related elements , So it's going to use erase and remove, So what's the difference between the two ? From the official documents , We can get the following information erase : explain :Removes fro ...

  6. Error detected while processing function pythoncomplete#Complete: Error resolution

    python vim After the environment is configured , Strange things always come up :Error detected while processing function pythoncomplete#Complete: Annoying mistakes , many ...

  7. Android Studio Occupy C Disk memory

    Use Android Studio When , Will find , In all kinds of download and import ,C Disk memory consumption is very fast , So I looked at the configuration .

  8. October 07th 2017 Week 40th Saturday

    Knowledge is a treasure but practice is the key to it. Knowledge is a treasure , But practice is the key to it . Experience often comes fro ...

  9. HDU 4716 A Computer Graphics Problem ( Water problem )

    A Computer Graphics Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  10. scrapy actual combat 2, Use the built-in xpath,re and css Extract value

      Take Bole online articles as the crawling target blog.jobbole.com, Found in " The latest article " You can see all the articles in the options   Generally speaking , It can be used scrapy The built-in xpath perhaps css To extract data , It's defined in ...