Skip to content

Instantly share code, notes, and snippets.

@shantanuo
Created January 19, 2013 08:31
Show Gist options
  • Save shantanuo/4571439 to your computer and use it in GitHub Desktop.
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
#!/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