Jump to content

MadTiago

Inactive Member
  • Posts

    22
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by MadTiago

  1. You're probably using a different port on sshd_config.

     

    To use a ssh tunnel to connect to mysql, you just need to create a local mysql user on your server and then configure navicat to use local user + ssh tunnel like this:
    https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

    https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

     

    If you changed ssh port, you need to reload/restart ssh daemon:

     

    service sshd restart
    • Love 2
  2. You could improve your coding even more.

    • Try using PDO/MySQLi instead of php's native mysql lib
    • Use some sort of config options instead of harcoding databases/tables names
    • If you declare every function as "public" even if they don't need to be public, it will make no sense to specify it's visibility
    • Try using | as a separator instead of :::
    • When you write player's cache, you can use a foreach to iterate through player data, no need to write all those lines
  3. You're running game file on share directory, when you're not supposed to.

    The share directory is used to "share" (hence the name) the files with game channels/cores using symbolic links. Think of it as a "common" directory.

    This method allows you to replace the game/db file on a single directory (in this case it's share) affecting every directory that has a symbolic link poiting to game/db files.

    When you run the game file, it tries to load the CONFIG file, but that doesn't exist on share dir since each channel/core has a unique CONFIG file (that's why you don't "share" it).

    • Love 1
  4. M2 Download Center

    This is the hidden content, please
    ( Internal )

    With this modifications to the original make.sh you can comment your locale_list.

    Prerequisites

    • bash

    How to use?

    bash make.sh

    Source code

    #!/usr/local/bin/bash
    
    LIST_FILE='locale_list'
    BIN="./qc"
    
    if [ -r $LIST_FILE ]; then
    	rm -rdf object
    	mkdir object
    	while read line;
    		do
    			firstChar="${line:0:1}"
    			if [ "$firstChar" != "#" ] && [ -n "$firstChar" ]; then
    				quest=${line%#*}
    				$BIN $quest
    			fi
    		done < $LIST_FILE
    else
    	echo $LIST_FILE' is missing'
    fi

    Example locale_list

    # First quest
    quest1.quest
    
    quest2.quest # Second quest
    
    quest3.quest
    quest4.quest

    Hope you like it.

    • Metin2 Dev 7
    • Confused 1
    • Good 4
    • Love 11
  5. Hi, good afternoon.

    This is a very nice script but I have a little problem with the cron part and I would like to know if you also happens and if you could solve.

     

    I put in the crontab this to test it

    * * * * * root sh /Cron/auto_back.sh all
    

    It do the auto_back.sh every min, but not dump the tables and not upload the files, it generates a empty empyfiles.gz, to test if the cron works I put in the script header

    echo "test" >> /log_auto
    

    And It works, every mins. insert test in the /log_auto.

     

    If I do manually it works.

     

    Does anyone know how can be solved?

     

    Kind regards.

    You should leave /etc/crontab alone.

    Use crontab -e instead (no need to specify the user).

  6. Hey.

    I'm releasing my mysql backup script.

    Prerequisites

    • mysqldump
    • gzip
    • ncftp
    • ftp server properly set up
    How does the script works?
    • Dumps and compresses the desired mysql databases
    • Transfers compressed files to remote host
    • Removes local compressed files
    How to use?

    This script takes only one argument (mode).

    Mode defines which databases should be dumped.

    Run it as: 

    sh backupmysql.sh <mode>
    Check the source comments for available modes.

    Running automatically

    You can also define it to run automatically with a cronjob, and even run different modes on different times.

    To add a new cronjob, run:

    crontab -e

    Example cronjob (once a day):

    0 0 * * * sh /usr/home/someuser/backupmysql.sh all

    Script source:

    #!/bin/sh
    
    # Get mode from user input
    #	Allowed modes:
    #		all:		backups account, common, log, player, webserver
    #		game:		backups account, common, player
    #		gameLog:	backups log
    #		web:		backups webserver
    #		exceptLog:	backups account, common, player, webserver
    MODE=$1
    
    if [ "$MODE" == "" ]; then
    	MODE="exceptLog"
    fi
    
    # Bins
    MYSQLDUMP=`which mysqldump`
    GZIP=`which gzip`
    NCFTP=`which ncftp`
    
    # Date for folders and filenames
    DAY=$(date +"%Y-%m-%d")
    FILETIME=$(date +"%Y-%m-%d.%T")
    
    # Local backup folder (no trailing slash)
    LOCAL_FOLDER="/tmp/backup"
    
    # FTP Configuration
    REMOTE_HOST="x.x.x.x"
    REMOTE_USER="ftp_user"
    REMOTE_PASS="ftp_pass"
    REMOTE_FOLDER="/" # With trailing slash
    
    # MySQL Configuration
    MYSQL_USER="mysql_user"
    MYSQL_PASS="mysql_pass"
    
    # Which databases shall we backup?
    # Databases should be separated with a space
    DATABASES=""
    if [ "$MODE" == "all" ]; then
    	DATABASES="account common log player webserver"
    elif [ "$MODE" == "game" ]; then
    	DATABASES="account common player"
    elif [ "$MODE" == "gameLog" ]; then
    	DATABASES="log"
    elif [ "$MODE" == "web" ]; then
    	DATABASES="webserver"
    elif [ "$MODE" == "exceptLog" ]; then
    	DATABASES="account common player webserver"
    fi
    
    # Check if DATABASES var is set...
    if [ "$DATABASES" == "" ]; then
    	echo -e "033[31mThe specified mode doesn't exist...033[0m"
    	exit 1
    fi
    
    # Dump and compress
    for db in $DATABASES
    do
    	FILE=$db.$FILETIME.gz
    	echo -e "033[32mDumping $db!033[0m"
    	$MYSQLDUMP -u $MYSQL_USER -p$MYSQL_PASS $db | $GZIP -9 > $LOCAL_FOLDER/$FILE
    done
    
    # Transfer all backup files to remote host
    echo -e "033[32mnTransfering files!033[0m"
    $NCFTP -u$REMOTE_USER -p$REMOTE_PASS $REMOTE_HOST<<EOF
    mkdir $REMOTE_FOLDER$DAY
    cd $REMOTE_FOLDER$DAY
    lcd $LOCAL_FOLDER
    mput *
    quit
    EOF
    
    # Delete local dump files
    rm -f $LOCAL_FOLDER/*
    

    • Love 14
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.