From 04c09647d7d73a4a9b78db4e620b788bf4c1f24c Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Sat, 11 Jul 2015 11:22:54 -0400 Subject: [PATCH 1/4] Update DB Scripts Added backup / restore scripts. Added table size script Updated existing scripts to use variable location for mysql.cnf file --- servatrice/scripts/File.History | Bin 0 -> 3805 bytes servatrice/scripts/db_backup_all | 44 +++++++++++++++ servatrice/scripts/db_restore_all | 50 ++++++++++++++++++ servatrice/scripts/info_db_tablesize | 3 ++ .../maint_removeinactiveplayeraccounts | 3 +- servatrice/scripts/maint_replays | 3 +- servatrice/scripts/maint_sessions | 3 +- servatrice/scripts/setup_addfirstadmin | 3 +- 8 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 servatrice/scripts/File.History create mode 100644 servatrice/scripts/db_backup_all create mode 100644 servatrice/scripts/db_restore_all create mode 100644 servatrice/scripts/info_db_tablesize diff --git a/servatrice/scripts/File.History b/servatrice/scripts/File.History new file mode 100644 index 0000000000000000000000000000000000000000..00e52f20a863e12cb4e2e89dbd4750bcd5017504 GIT binary patch literal 3805 zcmb7Hc{J30A03l*C_9M|ku1Yx$wbx&V;GIW$TrN#I%MpMP-qZCrcg9wN>QF{S&OlR zs7RKwme7zjsVwj4dEV0Tynnni=bqpB{d2$P+~57&&;24`yO;$4Kma?S)Shmv$rh)f z%me`3U;qr@1whnQjzSVE=0c@!T6ck?*=_lZb27HX3KyCIsH`4bM9JJDnq%-xar;R?i)J#28I)2K8aa$p$nVHGRpzj>)a=ee>IelJ;etNNln@h}BadPpltP9Fo3rZ|= zX~>-AblK8jg5x+ee_3V^^fWmCI=E$cZPmBlOWBVIku^s5KRQxUoej$ECht!bs=^l) z?NfdBgjWDneB;&Av1&HdGo)|w+m6JyQSqbXyFp<3DN#<_vCp@>aDqe|35<0FxuQ5= zV&d55+0-^aq|xHcgFbm{FGgeOhK7t zP*9&32(tF|8&u)h5Zff)&$h{?^1yp_%#qZEGz*Wzm{hZD9w5JHiOGywFtNWQD%V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wTWx1M;m+-{oluf(JK?|X z8V2XquG!AHGkLdj+Ohx1`QQ89KRL|c+sfhXd^^KuJ6{3g<(G*65=9Kctti?~xN}Cg i6TSfbN%*f5%V6D_SOkoPb;~MjjK3A5a|Uy5z5NGqKSq22 literal 0 HcmV?d00001 diff --git a/servatrice/scripts/db_backup_all b/servatrice/scripts/db_backup_all new file mode 100644 index 00000000..42d329d2 --- /dev/null +++ b/servatrice/scripts/db_backup_all @@ -0,0 +1,44 @@ +#!/bin/bash +SLEEPTIME=5 +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +LOGAPPENDDATE=`date +%m%d%Y` +EXPIRATION=`date +%m%d%Y -d "-3 days"` +DBNAME="servatrice" +APPNAME="servatrice" +ROOTFOLDER="./backups" #set this to the root path you want backups to be stored in +BACKUPDIR="$ROOTFOLDER/$LOGAPPENDDATE/db/$APPNAME" +TABLES=( + "cockatrice_users" + "cockatrice_decklist_files" + "cockatrice_replays" + "cockatrice_buddylist" + "cockatrice_ignorelist" + "cockatrice_bans" + "cockatrice_sessions" + "cockatrice_decklist_folders" + "cockatrice_replays_access" + "cockatrice_games" + "cockatrice_games_players" + "cockatrice_uptime" + "cockatrice_schema_version" + "cockatrice_servermessages" + "cockatrice_servers" + "cockatrice_news" + "cockatrice_rooms" + "cockatrice_rooms_gametypes" + ) +/home/wwadmin/scripts/db_maint_logs +PROCESSNAME="mysqldump" +#COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` +if [ -z "$COMMANDRESULTS" ]; +then + [ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/ + for TABLENAME in "${TABLES[@]}" + do + BACKUPFILE="$BACKUPDIR/$APPNAME.$TABLENAME.sql.$LOGAPPENDDATE" + echo "Backing up DB Table [$TABLENAME]" + ionice -c3 nice -n19 mysqldump --defaults-file=$SQLCONFFILE $DBNAME $TABLENAME > $BACKUPFILE + sleep $SLEEPTIME + done + rm -rf "$ROOTFOLDER/$EXPIRATION/" +fi diff --git a/servatrice/scripts/db_restore_all b/servatrice/scripts/db_restore_all new file mode 100644 index 00000000..e1d1c354 --- /dev/null +++ b/servatrice/scripts/db_restore_all @@ -0,0 +1,50 @@ +#!/bin/bash +SLEEPTIME=5 +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +LOGAPPENDDATE=`date +%m%d%Y` +EXPIRATION=`date +%m%d%Y -d "-3 days"` +DBNAME="servatrice" +APPNAME="servatrice" +ROOTFOLDER="./backups" #set this to the root path that contains the backup files +BACKUPDIR="$ROOTFOLDER/$LOGAPPENDDATE/db/$APPNAME" +TABLES=( + "cockatrice_users" + "cockatrice_decklist_files" + "cockatrice_replays" + "cockatrice_buddylist" + "cockatrice_ignorelist" + "cockatrice_bans" + "cockatrice_sessions" + "cockatrice_decklist_folders" + "cockatrice_replays_access" + "cockatrice_games" + "cockatrice_games_players" + "cockatrice_uptime" + "cockatrice_schema_version" + "cockatrice_servermessages" + "cockatrice_servers" + "cockatrice_news" + "cockatrice_rooms" + "cockatrice_rooms_gametypes" + ) +/home/wwadmin/scripts/db_maint_logs +PROCESSNAME="mysqldump" +#COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` +if [ -z "$COMMANDRESULTS" ]; +then + [ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/ + for TABLENAME in "${TABLES[@]}" + do + BACKUPFILE="$BACKUPDIR/$APPNAME.$TABLENAME.sql.$LOGAPPENDDATE" + if [ -f "$BACKUPFILE" ] + then + echo "Restoring up DB Table [$TABLENAME]" + ionice -c3 nice -n19 mysql --defaults-file=$SQLCONFFILE $DBNAME < $BACKUPFILE + sleep $SLEEPTIME + else + echo "Missing backup file [$$TABLENAME]" + sleep $SLEEPTIME + fi + done + rm -rf "$ROOTFOLDER/$EXPIRATION/" +fi diff --git a/servatrice/scripts/info_db_tablesize b/servatrice/scripts/info_db_tablesize new file mode 100644 index 00000000..a558155e --- /dev/null +++ b/servatrice/scripts/info_db_tablesize @@ -0,0 +1,3 @@ +#!/bin/bash +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +mysql --defaults-file=$SQLCONFFILE -e 'SELECT table_name AS "Tables", round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "servatrice" ORDER BY (data_length + index_length) DESC;' diff --git a/servatrice/scripts/maint_removeinactiveplayeraccounts b/servatrice/scripts/maint_removeinactiveplayeraccounts index cf72f069..75b2775f 100644 --- a/servatrice/scripts/maint_removeinactiveplayeraccounts +++ b/servatrice/scripts/maint_removeinactiveplayeraccounts @@ -1,3 +1,4 @@ #!/bin/bash # SCHEDULE WITH CRONTAB BASED ON TIME PERIOD UNACTIVE ACCOUNT SHOULD BE REMOVED. UPDATE INTERVAL DATE TO BE NUMBER OF DAYS OLD (OR OLDER) TO REMOVE. -mysql --defaults-file=./mysql.cnf -h localhost -e 'delete from servatrice.cockatrice_users where registrationDate < DATE_SUB(now(), INTERVAL 5 DAY) AND active = 0'; +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +mysql --defaults-file=$SQLCONFFILE -h localhost -e 'delete from servatrice.cockatrice_users where registrationDate < DATE_SUB(now(), INTERVAL 5 DAY) AND active = 0'; diff --git a/servatrice/scripts/maint_replays b/servatrice/scripts/maint_replays index 1ce1b400..22f6c097 100644 --- a/servatrice/scripts/maint_replays +++ b/servatrice/scripts/maint_replays @@ -1,3 +1,4 @@ #!/bin/bash # SCHEDULE WITH CRONTAB BASED ON TIME PERIOD REPLAYS SHOULD BE SAVED UNTIL (EX: SCHEDULE ONCE A WEEK TO KEEP A WEEKS WORTH OF REPLAYS IN THE DB) -mysql --defaults-file=./mysql.cnf -h localhost -e 'truncate table servatrice.cockatrice_replays;truncate table servatrice.cockatrice_replays_access' +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +mysql --defaults-file=$SQLCONFFILE -h localhost -e 'truncate table servatrice.cockatrice_replays;truncate table servatrice.cockatrice_replays_access' diff --git a/servatrice/scripts/maint_sessions b/servatrice/scripts/maint_sessions index 2c41da6d..69e531ce 100644 --- a/servatrice/scripts/maint_sessions +++ b/servatrice/scripts/maint_sessions @@ -1,3 +1,4 @@ #!/bin/bash # SCHEDULE WITH CRONTAB TO RUN ONCE A MONTH -mysql --defaults-file=./mysql.cnf -h localhost -e "delete from servatrice.cockatrice_sessions where start_time < DATE_SUB(now(), INTERVAL 1 MONTH)" +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +mysql --defaults-file=$SQLCONFFILE -h localhost -e "delete from servatrice.cockatrice_sessions where start_time < DATE_SUB(now(), INTERVAL 1 MONTH)" diff --git a/servatrice/scripts/setup_addfirstadmin b/servatrice/scripts/setup_addfirstadmin index 91731559..17c2d881 100644 --- a/servatrice/scripts/setup_addfirstadmin +++ b/servatrice/scripts/setup_addfirstadmin @@ -1,3 +1,4 @@ #!/bin/bash # SCRIPT TO ADD THE FIRST ADMIN USER NAMED SERVATRICE WITH THE PASSWORD OF PASSWORD -mysql --defaults-file=./mysql.cnf -h localhost -e "insert into servatrice.cockatrice_users (admin,name,password_sha512,active) values (1,'servatrice','jbB4kSWDmjaVzMNdU13n73SpdBCJTCJ/JYm5ZBZvfxlzbISbXir+e/aSvMz86KzOoaBfidxO0s6GVd8t00qC0TNPl+udHfECaF7MsA==',1);" +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +mysql --defaults-file=$SQLCONFFILE -h localhost -e "insert into servatrice.cockatrice_users (admin,name,password_sha512,active) values (1,'servatrice','jbB4kSWDmjaVzMNdU13n73SpdBCJTCJ/JYm5ZBZvfxlzbISbXir+e/aSvMz86KzOoaBfidxO0s6GVd8t00qC0TNPl+udHfECaF7MsA==',1);" From 10019bf985c3bd105f657118d3b35acec01fe316 Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Sat, 11 Jul 2015 15:41:59 -0400 Subject: [PATCH 2/4] Cleanup Added -u options by request. Removed line for running log cleanup prior to backup. Added abort warning. --- servatrice/scripts/db_backup_all | 9 ++++++--- servatrice/scripts/db_restore_all | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/servatrice/scripts/db_backup_all b/servatrice/scripts/db_backup_all index 42d329d2..ce3433ab 100644 --- a/servatrice/scripts/db_backup_all +++ b/servatrice/scripts/db_backup_all @@ -1,4 +1,5 @@ #!/bin/bash +set -u SLEEPTIME=5 SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file LOGAPPENDDATE=`date +%m%d%Y` @@ -25,11 +26,11 @@ TABLES=( "cockatrice_servers" "cockatrice_news" "cockatrice_rooms" - "cockatrice_rooms_gametypes" + "cockatrice_rooms_gametypes" ) -/home/wwadmin/scripts/db_maint_logs + PROCESSNAME="mysqldump" -#COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` +COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` if [ -z "$COMMANDRESULTS" ]; then [ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/ @@ -41,4 +42,6 @@ then sleep $SLEEPTIME done rm -rf "$ROOTFOLDER/$EXPIRATION/" +else + echo "Backup in progress, aborting" fi diff --git a/servatrice/scripts/db_restore_all b/servatrice/scripts/db_restore_all index e1d1c354..7dcb4527 100644 --- a/servatrice/scripts/db_restore_all +++ b/servatrice/scripts/db_restore_all @@ -1,4 +1,5 @@ #!/bin/bash +set -u SLEEPTIME=5 SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file LOGAPPENDDATE=`date +%m%d%Y` @@ -25,11 +26,11 @@ TABLES=( "cockatrice_servers" "cockatrice_news" "cockatrice_rooms" - "cockatrice_rooms_gametypes" + "cockatrice_rooms_gametypes" ) -/home/wwadmin/scripts/db_maint_logs + PROCESSNAME="mysqldump" -#COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` +COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` if [ -z "$COMMANDRESULTS" ]; then [ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/ @@ -47,4 +48,6 @@ then fi done rm -rf "$ROOTFOLDER/$EXPIRATION/" +else + echo "Restore in progress, aborting" fi From 9338e7e71f3ec9e28763d0e23800763ef1773123 Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Sat, 11 Jul 2015 16:35:12 -0400 Subject: [PATCH 3/4] Added -e option Added -e option by request Updated process checking method to allow -e option --- servatrice/scripts/db_backup_all | 4 ++-- servatrice/scripts/db_restore_all | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/servatrice/scripts/db_backup_all b/servatrice/scripts/db_backup_all index ce3433ab..35aa5d41 100644 --- a/servatrice/scripts/db_backup_all +++ b/servatrice/scripts/db_backup_all @@ -1,5 +1,6 @@ #!/bin/bash set -u +set -e SLEEPTIME=5 SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file LOGAPPENDDATE=`date +%m%d%Y` @@ -30,8 +31,7 @@ TABLES=( ) PROCESSNAME="mysqldump" -COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` -if [ -z "$COMMANDRESULTS" ]; +if [ "$(pgrep $PROCESSNAME)" == "" ]; then [ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/ for TABLENAME in "${TABLES[@]}" diff --git a/servatrice/scripts/db_restore_all b/servatrice/scripts/db_restore_all index 7dcb4527..37d1f31e 100644 --- a/servatrice/scripts/db_restore_all +++ b/servatrice/scripts/db_restore_all @@ -1,5 +1,6 @@ #!/bin/bash set -u +set -e SLEEPTIME=5 SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file LOGAPPENDDATE=`date +%m%d%Y` @@ -30,8 +31,7 @@ TABLES=( ) PROCESSNAME="mysqldump" -COMMANDRESULTS=`ps -e |grep $PROCESSNAME |grep -v grep` -if [ -z "$COMMANDRESULTS" ]; +if [ "$(pgrep $PROCESSNAME)" == "" ]; then [ ! -d $BACKUPDIR ] && mkdir -p $BACKUPDIR/ for TABLENAME in "${TABLES[@]}" From ff5ea7fc1fc380aa1b0626c28c8ffcd61c58e458 Mon Sep 17 00:00:00 2001 From: woogerboy21 Date: Sat, 11 Jul 2015 17:03:37 -0400 Subject: [PATCH 4/4] Added log maint script Added log maint script --- servatrice/scripts/File.History | Bin 3805 -> 4512 bytes servatrice/scripts/maint_logs | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 servatrice/scripts/maint_logs diff --git a/servatrice/scripts/File.History b/servatrice/scripts/File.History index 00e52f20a863e12cb4e2e89dbd4750bcd5017504..8ea21e2cadbc25ba09f06c8c66b79ff6dca44eec 100644 GIT binary patch delta 1144 zcmcaByFj@~)hChFv&(&cx`%Sh8($uY<>gG3UF_%PR~_CVy6K;U@EyVP zg%i{Qw{-r@+7uyIe`a~qlw8xs>=TEs^)_C$6|!5hwpvNo>u%J|EooEEi-q(mrOQ05 ztX}nG`le&jSFSz{+%HpMIz?~ks;wJ8a9p<4+|;t_vb)5qeM{fYnk2SV@BaT6VK15e zOiQm=^GDy7;oR=bxlgp!KKpB?*?uc~X7lULKYw2N$%+U>k6DvvFdA@qY+4wawQ*r6 z*QU*v7~7Z_CryrIG2{wevM@Ao@xstwi#JbUna;%6HCczx{AR}Yd$_*{F53^E&ZXDg<*kd&%zL`Lr2fn!3(v&|zWw>PwqE|wV&=_j^&2O!MSc}= z6TZgDBUaBWz~^+yt6(LsKuc;f6E9QnCidP}p^{evzpPmDUEW(UTEbFm&be(SvHcrb zog-XQ>uy>$%gC0qdWN|?&z^B8&35bT-COJeycwCqxpAdsPM}|bz>GnGp`j7P!j-gH zAxRtAG+?B@wYFWN+1EJw6%6n91IJN}WQIyjj^mVa*AI@0fu0^MQB(inW2N delta 479 zcmZ3Wd{>qyz?+#xgn@~HgJE;jWJ?}bt_e;HLxqk^1mevdJl2d%9$l0D84b8JrY#Kh znz}Ib)zr zUI_3;X!7WK?H0B{r>>HTfkBm(fk6^QQx7A<GkSy7-yP&goKOsbkZgI|V8fqn8eeib25cp%GG7fpV{FT)(c!7y2e zLk6TD6gbE#db1|m2*@xlog68kBm@c~WXZWnlY4=Z=O?ccP?rJ)Re(1u8z>OifiMv0 J)G{6r4*=ttbqN3f diff --git a/servatrice/scripts/maint_logs b/servatrice/scripts/maint_logs new file mode 100644 index 00000000..c218ff36 --- /dev/null +++ b/servatrice/scripts/maint_logs @@ -0,0 +1,4 @@ +#!/bin/bash +#SCHEDULE WITH CRONTAB AND ADJUST THE INTERVALS FOR THE NUMBER OF DAYS OF LOGS TO KEEP IN THE DATABASE +SQLCONFFILE="./mysql.cnf" #set this to the path that contains the mysql.cnf file +mysql --defaults-file=$SQLCONFFILE -h localhost -e 'delete from servatrice.cockatrice_log where log_time < DATE_SUB(now(), INTERVAL 10 DAY)'