mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 08:34:52 -07:00
Script Cleanup
Added the ability to specify custom database name. Added the ability to specify custom table prefix. Created sub folders for operating systems.
This commit is contained in:
parent
8a0fdd2089
commit
44025c667e
14 changed files with 51 additions and 23 deletions
47
servatrice/scripts/linux/db_backup_all
Normal file
47
servatrice/scripts/linux/db_backup_all
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#!/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`
|
||||
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"
|
||||
)
|
||||
|
||||
PROCESSNAME="mysqldump"
|
||||
if [ "$(pgrep $PROCESSNAME)" == "" ];
|
||||
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/"
|
||||
else
|
||||
echo "Backup in progress, aborting"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue