6
【旧代码】mysql备份的shell脚本
source link: https://byronhe.com/post/2011/11/15/mysql-backup-script/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【旧代码】mysql备份的shell脚本
2011-11-15
思路类似 http://bazaar.launchpad.net/~lenzgr/mylvmbackup/trunk/view/head:/mylvmbackup.pl.in
#!/bin/sh
bk_to="/var/mysql-backup-`date +%Y-%m-%d-%k-%M-%S |tr -d ' '`"
user_name="root"
user_pw="dev"
sql="
flush tables with read lock;
system cp -pR /var/lib/mysql $bk_to;
unlock tables;
"
mysql -u $user_name -p$user_pw -e "$sql"
echo $sql
tar cjf $bk_to.bz2 $bk_to
rm -rf $bk_to
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK