Jump to content
The forums will be going offline for an extended maintenance period at 1400hrs GMT on 19th June 2025. The number of hours for this downtime is intentionally not advertised due to the nature of these upgrades. ×
  • 0

How can this work?


Brave

Question


  • Group:  Members
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  208
  • Reputation:   11
  • Joined:  05/31/12
  • Last Seen:  

 

Heyho,

I stopped my work on any ragnarok server. So this is a small farewell gift.

This small scripts can be used as Cronjob (http://en.wikipedia.org/wiki/Cronjob) to decrease you administrative work.

You normaly just have to change the config variables.

Script 1: Auto RO server restart when crashed
(should be started via cronjob every 5 minutes or less)

#!/bin/bash

###CONFIG START###
SERVER_USER="foo"
PATH_TO_RO="/home/bar/rathena/"
###CONFIG END###


ERROR=0
if [ "$(ps auxf | grep 'login-server' | grep -v 'grep')" == "" ]; then
        ERROR=1
fi
if [ "$(ps auxf | grep 'char-server' | grep -v 'grep')" == "" ]; then
        ERROR=1
fi
if [ "$(ps auxf | grep 'map-server' | grep -v 'grep')" == "" ]; then
        ERROR=1
fi
if [ $ERROR == 1 ]; then
        su $SERVER_USER | $PATH_TO_RO/athena-start restart
fi

Script 2: SQL Backup
(should be started every day)

#!/bin/bash

###CONFIG START###
PATH_TO_BACKUPS="/home/foo/backups"
DB_HOST="localhost"
DB_USER="foo"
DB_PASSWORD="secretpw"
WHICH_DATABASES="ragnarok"
USER_NAME="foo"
USER_GROUP="bar"
###CONFIG END###

find -P $PATH_TO_BACKUPS -maxdepth 1 -type f \( -name '*.sql' \) -ctime +15 -exec rm {} \;
mysqldump -h$DB_HOST -u$DB_USER -p$DB_PASSWORD --databases $WHICH_DATABASES > $PATH_TO_BACKUPS/$(date +%Y-%m-%d).sql
chown $USER_NAME:$USER_GROUP $PATH_TO_BACKUPS/$(date +%Y-%m-%d).sql

 

Script 3: Logs -> History DB

If you have the logs and ragnarok tables in the same database, you can may think of archive some of old logs to another database.
(should be started 2 times a month)

#!/bin/bash

###CONFIG START###
PATH_TO_RO="/home/bar/rathena"
DB_HOST="localhost"
DB_USER="bar"
DB_PASSWORD="secretpw"
DB_RAGNAROK_DATABASE="ragnarok"
DB_LOG_DATABASE="ragnarok-log"
###CONFIG END###


mysqldump -h$DB_HOST -u$DB_USER -p$DB_PASSWORD --compact --no-create-info $DB_RAGNAROK_DATABASE atcommandlog branchlog charlog chatlog npclog picklog zenylog > $PATH_TO_RO/temp.sql
mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWORD -D$DB_RAGNAROK_DATABASE -e"DELETE FROM atcommandlog WHERE 1=1; DELETE FROM branchlog WHERE 1=1; DELETE FROM charlog WHERE 1=1; DELETE FROM chatlog WHERE 1=1; DELETE FROM npclog WHERE 1=1; DELETE FROM picklog WHERE 1=1; DELETE FROM zenylog WHERE 1=1;"
mysql -h$DB_HOST -u$DB_USER -p$DB_PASSWORD -D$DB_LOG_DATABASE < $PATH_TO_RO/temp.sql
rm $PATH_TO_RO/temp.sql

(before you start this script, you should insert a structure only dump into your history database)

 

I hope this may help you and the config is understandable.

Greetings,
Loki1991(before you start this script, you should insert a structure only dump into your history database)


Edited by loki1991, 01 February 2014 - 03:15 AM.

 

 

 

 

    •  
    • Like the title says how does it work?

BUMP BUMP!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...