Use shell to write a mysql data backup script and shellmysql Data Backup
Ideas
It's actually very simple.
Write a shell script and use mysqldump of mysql to export data to the corresponding SQL file. Use crontab of linux to regularly run the corresponding script and save the
First modify the script for necessary configuration, and then run it as the root user. 1. first, the first parameter is used for remote backup. 2. local parameter for local backup 3. parameter-free remote backup note: you need to add a user to the Mysql user on another host .. where you need to configure: # definehosta
after the measurement product deploys the service end, because the service side has each kind of encapsulation encrypted attachment, the file and so on data, in order to safeguard the security of the information, in addition to establish the high availability backup mechanism, we can through the batch script, unifies to the system plan to carry on the local or the offsite
Today an accident, I wrote the diary of the big half month the encrypted file is damaged and cannot be recovered. He decided to write a dedicated backup script file.
The main idea is to create a folder under current directory backup based on today's date, and then copy the files to that folder.
The script files are as
Article Title: tiptop automatic backup script backup. sh. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
# Create a crontab Scheduler
Crontab-e
0 *** sh/u3/backup/tool/
This script implements the following functions: 1. Backing up mysql databases online; 2. Saving backup logs to log files; 3. compressing data backup files; 4. Remotely ftp the compressed file to the backup server; 5. deleting data that has been backed up locally for more than seven days is mainly to prevent the abnorma
Tags: mysql scheduled backup script diary cutMost of the diary cutting and backup mechanisms are the same: The following is the Nginx diary cutting script#!/bin/bashLogPath = '/home/nginx/log 'Nglogs = '/opt/nginx/logsMkdir-p $logpath/$ (date +%y)/$ (date +%m)MV $nglogs/access.log $logpath/$ (date +%y)/$ (date +%m)/acc
MySQL database Regular automatic backup script, mysql database scriptThe most important thing for a Web system is the security and integrity of the database.It is very important to back up data regularly. Do not be lazy on this issue. If your important data is lost, it will make you cry.Export table structure and data mysqldump-uroot-pmypassword -- databases fansunion -- result-file =/var/www/
install MySQL for you"
wgetHttps//repo.mysql.com//mysql57-community-release-el7-10.noarch.rpm--no-check-certificate
rpm-UVH mysql57-community-release-el7-Ten. noarch.rpmfi#安装系统Yum Installmysql-community-Server #启动服务 service mysqld start #查看临时密码文件grep 'Temporary password'/var/log/mysqld.log Rehat backup MySQL Script1. The code is as follows: #!/bin/Bash #保存备份个数number=3#备份保存路径 Backup_dir=/root/mysqlbackup #日期DD=`Date+%y%m%d ' #备份工具 tool=mysqldump #用
Nginx diary cutting script and MySQL regular backup script
Most of the log cutting and backup mechanisms are the same: Below is the Nginx diary cutting script#! /Bin/bashLogpath = '/home/nginx/Log'Nglogs = '/opt/nginx/logsMkdir-p $ logpath/$ (date + % Y)/$ (date + % m)Mv $ n
Join the Crontab timed task to perform daily. The effect is: Back up the database to the specified directory every day, delete the files backed up 10 days ago.
Here's what the script reads:
The code is as follows
Copy Code
#!/bin/bashMysql_host= "127.0.0.1"Mysql_user= "Root"Mysql_passwd= "********"Back_dir= "/www/backup/database/"ignore_db= "Information_schema|mysql|performance
-----SQL ScriptsDECLARE @fileName varchar (255),--Define the backup file name variable@dbname varchar (255)--Define the backup database name variableDECLARE mycursor cursor Fast_forward for select name from master: sysdatabases ORDER BY name--Define a cursor objectOpen MyCursor--opening cursorsSet @dbname = ' PYSF 'Set @fileName = ' D:\bakck\1\ ' [email protected]+convert (varchar), GETDATE (), + '. Bak ')-
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.