Created
January 19, 2013 08:31
-
-
Save shantanuo/4571439 to your computer and use it in GitHub Desktop.
Incremental backup of customer_ticket table and all data backup of other tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mydb=$1 | |
> $mydb.sql | |
param="-uroot --compact $mydb" | |
yesterday=`date '+%Y-%m-%d 00:00:00' -d "1 day ago"` | |
today=`date '+%Y-%m-%d 00:00:00'` | |
mywhere="lastupdate>'$yesterday' and lastupdate<'$today'" | |
# incremental data backup | |
mysqldump $param customer_ticket --no-create-info --where="$mywhere" >> $mydb.sql | |
# full backup of small tables | |
while read tbl_name | |
do | |
mysqldump $param $tbl_name >> $mydb.sql | |
done << heredoc | |
cust_types | |
concessions | |
flat_fare | |
routes | |
ticket_window | |
window_bill | |
heredoc | |
# compress zip | |
tar cvzf $mydb.sql.tar $mydb.sql | |
# scp file to other server | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment