How do I regularly back up MySQL Data? I have provided several methods for you to see. Supports regular and automatic backup of mysql Data in linux.
MySQL: shell script for automatic database backup in Linux
The programs on Linux Server Update the MySQL database every day, so they think of writing a shell script, combined with crontab, to regularly back up the database. In fact, it is very simple, mainly using the MySQL mysqldump command.
The script content is as follows:
#! /Bin/sh
# File:/home/mysql/backup. sh
# Database info
DB_NAME = "test"
DB_USER = "username"
DB_PASS = "password"
# Others vars
BIN_DIR = "/usr/local/mysql/bin"
BCK_DIR = "/home/mysql/backup"
DATE = 'date + % F'
# TODO
$ BIN_DIR/mysqldump-opt-u $ DB_USER-p $ DB_PASS $ DB_NAME | gzip> $ BCK_DIR/db_1_date.gz
Then add the script to the/etc/crontab scheduled task:
01 5 ** 0 mysql/home/mysql/backup. sh
All right, the system will automatically run the backup. sh file to back up the MySQL database at every Sunday.
/Home/www/inc/back