For server admins: Chat log backup Utility

Tips, tactics, and general discussion for Evochron Legacy.
Kronous
Ensign
Ensign
Posts: 18
Joined: Wed Jan 18, 2012 8:22 am

For server admins: Chat log backup Utility

Post by Kronous »

This is written in simple batch and i am still working on it.

Current Code

Code: Select all


@echo off
title Evochron Chat log backup utility
:BEGIN

::Set Values for Variable TME/Time
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%yyyy%-%mm%-%dd%
FOR /F "TOKENS=4*" %%A IN ('TIME/T') DO SET time=%%A
SET tme=%time%

::Set Variables for Directory/File (SET THESE)
set dir="C:\\sw3dg\\EvochronMercenaryServer\\chatlog.txt"
set cdir="C:\\sw3dg\\EvochronMercenaryServer\\ctbackups\\"
set file="%date%_%random%_%random%"
set extn=".log"
set vdir="%cdir%/%date%"
set dly=600


ECHO Copied at %tme%.

md %cdir%/%date%
copy %dir% /-y /v %vdir%\\%file%%extn%
echo Waiting around 10 minutes to save again...
ping 127.0.0.1 > NUL -n %dly%

goto BEGIN
pause

Currently using the default settings on this it
backs up your servers chat log every 10 minutes into a folder called ctbackup in a subfolder per day.

so

Code: Select all

C:\\sw3dg\\EvochronMercenaryServer\\ctbackups\\2012-01-22
For example.

Setting Variables..
Settable variables are to make this work how you want it too.

dir variable is the location of the chatlog, i dont think this really changes unless your server is not in the default location. change the dir variable to the location of your chat log file.

cdir variable is the location you want the logs to save by default. this is the main backups folder

file variable is the name of the saved file. By default it saves a file with the date_random number_random number format. This ensures that they will not likely override each other. I am trying to get a date_time version to work but it is being a pain in the butt.

extn variable is the desired extension you want the file to save to. I suggest either .txt or .log but you can make it anything you want really.

dly variable is the amount of time in seconds that it waits to repeat the process.

vdir Unless you know what you are doing i do not suggest you tinker with that at the moment it takes the cdir variable and the date variable and uses it to create the folder within the main backup folder that is used per day.

Tips on using..
I do not suggest using any less then 300 in dly as it gets very spammy. I had it running on 60 last night over night and woke up to find over 600MB on log files >.> that was over 2000 separate files.

Instructions..
Copy the main box up there and paste into a blank text file in your evochron server directory or anywhere really. Then hit Control + S, change the "save document type" setting to all files. then save the file as backupchat.bat or .cmd. You can name it anything you want. then run it. If you get any errors please drop them here or u2u me.

Other stuff..
I am going to try to make this work better and cleaner but this is literally the most advanced thing i have ever coded in batch. I use it personally and just though it could help new server admins out. All feedback is welcomed, and if you need help feel free to u2u me or post whats wrong here.

Kronous
Admin- Evochron Horizons.

[Edited on 1-22-2012 by Kronous]