思路类似 http://bazaar.launchpad.net/~lenzgr/mylvmbackup/trunk/view/head:/mylvmbackup.pl.in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #!/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 |
---|