您好,欢迎访问一九零五行业门户网

A Simple MySQL Daily Backup Script_MySQL

06.23.2014|69 views|
related microzone resourcesclustrix whitepapers
infographic: the future of the database
what we offer: clustrix features
proven in production: clustrix case studies
like this piece? share it with your friends:
|more
using the mysql export script i've showed from thelast post(assuming you saved it in a file named $home/database-export.sh), you may now perform a daily backup with your crontab service like this.
#file: mysql-backups.shdir=`dirname $0`echo backup db with export script.$dir/database-export.shecho moving exported files into backup dir.db_bak_dir=$home/mysql-backups/`date +%a`echo removing old file (if exists) and saving new backup into $db_bak_dirif [[ -e $db_bak_dir ]]; thenrm -fv $db_bak_dir/*elsemkdir -p $db_bak_dirficp -v $dir/*.sql $db_bak_dir
this script should create a daily folder under your home directory, for example like $home/mysql-backups/mon, tue, wed etc. it should save up to 7 days in a week if you run this with a daily cron job.
# crontab -e@daily $home/mysql-backups.sh > /dev/null 2>&1

this is not the most robust way of backing up your db, but it's a simple solution if you just want something quick up and running without worry too much.
published at dzone with permission ofzemian deng, author and dzone mvb. (source)
(note: opinions expressed in this article and its replies are the opinions of their respective authors and not those of dzone, inc.)
tags:backupmysqltips and trickssql
其它类似信息

推荐信息