The Third Reminders email bug fix - contributed by arnabnaha
[openemr.git] / interface / main / backuplog.sh
blob8464b9b4cf0f60b9d6f8bdc70155e667e670a680
1 #/bin/bash
2 # $1 - mysql user $2 mysql password $3 mysql Database $4 Log backup directory
4 # Create a temp table as that of Eventlog
5 mysql -u $1 -p$2 -D $3 -e "create table if not exists log_new like log"
6 # Rename the existing Event table to Event_backup & New Event table to Event table
7 mysql -u $1 -p$2 -D $3 -e "rename table log to log_backup,log_new to log"
8 # Dump the Backup table
9 mysqldump -u $1 -p$2 --opt --quote-names -r $4 $3 --tables log_backup
10 if [ $? -eq 0 ]
11 then
12 # After Successful dumping, drop the Backup table
13 mysql -u $1 -p$2 -D $3 -e "drop table if exists log_backup"
14 else
15 # If dumping fails, then restore the previous state
16 mysql -u $1 -p$2 -D $3 -e "drop table if exists log"
17 mysql -u $1 -p$2 -D $3 -e "rename table log_backup to log"