Alibabacloud.com offers a wide variety of articles about mysql backup shell script, easily find your mysql backup shell script information here online.
Mysql backup policies can be divided into four types:
1) directly copy database files (not recommended)
2) use mysqlhotcopy to back up the database
3) Use mysqldump to back up the database
4) use the master-slave replication mechanism (for real-time database backup)
Mysqldump is widely used and easy to operate. The following describes the mysqldump
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 tha
First step: Define your backup directory on your Linux server:
Copy Code code as follows:
Mkdir/var/lib/mysqlbackup
Cd/var/lib/mysqlbackup
The second step: The following is the most important step, is to write a scheduled backup script.
Copy Code code as follows:
VI dbbackup.sh
The code file is as follows
Tags: data shell crontab MySQL backup
Use mysqldump to back up MySQL data for a fixed time of day.
#!/bin/bash
#每天早上4点, MySQL backup data orangleliu
#chmod backup.sh
#crontab-E
#0 4 * * */home/erya/run/moniter/mysql
Tags: shell mysql mysqldump(1) Ideas(2) Practical casesWrite MySQL database backup script, you can backup any database, enter a, backup a library, enter B,
;source D:/i5a6.sql
Above all is the comparison scattered code, below we look at the shell code
The first thing I want to bring to you in this article is the full script. The script is described later. I assume you already know shell scripting, mysqldump and crontab.
Database Export Code
The cod
When there is more and more data in the database, how important is data backup. Next we will use shell scripts + crontab scheduled tasks to back up MySQL data (supporting multiple databases ), I will not explain the usage of shell and crontab too much here. If you are not familiar with it, you can refer to relevant mat
Shell simple full-backup mysql script case [root @ cacti mysql] # cat backup. sh #! /Bin/sh www.2cto.com # created by taiyang #2012-9-16 # function: backup
#!/bin/bash# every morning at 4, MySQL backs up data #chmod theBackup.SH#crontab-e#0 4* * * */home/erya/run/moniter/mysql_backup.SHUser="radius"Password=""Host="localhost"db_name="radius"#backup Directory Base_dir="/home/backup"Backup_log="${base_dir}/mysql_backup.log"Backup_path=${base_dir}#file InfoDate=$(Date+"%y-%m-%d") filename= $
#!/bin/bash #this is a script of MySQL backup if [!-d/mydata/data1/backup]; then mkdir/mydata/data1/backup fi CD
/mydata/data1/backup file=$ (find.-type f-mtime-7 | grep. *all.sql) #查找7天内是否有备份的文件 echo $file if [-Z $file]; then e
Http://www.cnblogs.com/bruceleeliya/archive/2012/05/04/2482733.htmluse mysqldump to back up the database, upload to the backup server via FTP, and keep the backup files locally. Create a new Shell script filevi/home/work/backup.shAdd the following content:#! /bin/bashsqlbakname=_u1_sql_$ (date +%y%m%d). Tar.gzmysqldump
yesterday's backupBin_dir= "/usr/local/mysql/bin"Bck_dir= "/home/zhangy/database_bak" # Backup pathCD $BCK _dir# Delete Previous backup of this database, because my Linux also has 2G hard disk space, depressed.If [-F $YESTERDAY $db_name ". sql"]ThenRm-f $YESTERDAY $db_name ". sql"Fi# Backup${bin_dir}/mysqldump--opt-u$
Recently, the company has a need to query the MySQL database from the status of 60 data and export.
The instance code is as follows :
#!/bin/bashDir= "/cache1" # #要存到导出数据的目录名open= "Open" # #导出数据的文件名称Open_dir= "${open}.$ (date +%y%m%d)" # #导出数据的文件名称, distinguished by dateDb= "/OPT/TRUSTEDM/MYSQL/CURRENT/BIN/MYSQL-UROOT-PMV_XQ_MV" # #数据库连接语句$db-dmed_001-e "Select
attention to the next:
The shell script under 01.linux defines the format of the variable as: key=value, notice that there is no space before or after the "=" between them, or the system cannot confirm the variable.02. The line marked in red, the first character that resembles a single quote "'" is actually not a single quote, and its input key is below the ESC key of the keyboard.03. This
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.