• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OpenTibia Backup everything automated, windows.

Kavalor

(Real)Creator of ChaosOT
Joined
Dec 13, 2007
Messages
242
Best answers
0
Reaction score
42
Location
Washington State, USA
Because I have not added any content for a while, and should kneel at the altar in service of some others.

This will assume you can make basic task schedules in windows as well as have a server, client, website and database needing backed up.
This will assume you can make a bat file and edit things with common sense.
This will assume you have a daily serversave.



Please note you will need the bat at the end fully done before you can make the task scheduler locate it for running.


My save will occur at 12:05, my backups will execute, store zipped files in external media drives as well as other drives. It will pull and compress my DB and backup my client/website/game server and all files inside of said dir's. The function will COPY everything to an area, make it have a nice structure and compress it. After compression cleanup will be performed and copies will be distributed to safe locations(they can also be google drive stores). After all of that the task scheduler in windows should be ordered to run the server again, completing the cycle of life. Ok so here we go with the task schedule

1576830679831.png
Locate task scheduler via a search or in control panel/admin tools or wherever it is in your version of windows.

1576830649478.png
Creating these is simple, they are basic tasks, triggered by time. One will be to start the backup bat I will show later in this thread and give the code for. One will be for restarting the server after the entire process is done, one is for warming up the usb stick pre copy. These are very safe to do step by step wizard crating basic tasks to make them occur and should not need any explaining. You are doing the same thing in all 3 cases, waiting for a certain time and launching a program from a directory. The order is important, this should all occur AFTER the server closes.

Usb warmup just loads a simple text document from a 1TB-USB stick i have plugged in, this will cause an error if it is not there, if it is there it will trigger windows to basically get it ready so when it comes time to use it a few minutes later there is less system lag.

Backups will issue a call to run the .bat I provite the code for

bravestart is just a command to rerun your server.

Your times for all of these functions you will need to sort out on your own as R/W speeds of every computer is unique and USB drives or copies over ect will be different on various computers, set times and test it. I have mine set to make a lot of free space to be safe, I have multiple NVME M2 Drives with really strong read write and my copies move very quickly but I still make a lot of space to ensure all task can flow without fail in the given time frames and be 100% automated from a serversave to server back up for players.

Here is a simple config for launching any of the stated needs above...

1576831308569.png1576831338622.png


1576831407708.png
Conditions tab , nothing special unless running on a laptop? probably not doing that! :p

for settings tab, Allow task to be run on demand and force stop the task if it does not end when requested.


-------------------------------BAT------------------------------------

Here is the backup bat, there are many thing you will need to change like where to backup things and what to backup. This will not be easy and is something you must sort out for your own config. I am backing up EVERYTHING as well as multi storing the archives for maximum protection. You may want more or less and this will be on you to sort out.

Make a bat file and include....
every line starting with -- Should be deleted from the code and is just for you to understand the line ABOVE IT
Also most lines have (2) directories! from and to for the copy process look carefully and set both of your own paths or it will fail.

Code:
xcopy "V:\Master\data\logs\." "V:\WebServer\WebServer\ssl" /D /K /H /Y
--I use this to push my gm commands to the website so transparency exist....not needed line. You can delete this or make your own

xcopy /e "V:\Master\." "C:\Users\username\Desktop\Schedueled Backups\AllBackups\Server" /D /K /H /Y
-- I use this to backup all server files for the game world, this would fetch the scripting, mapping ect ect in the server folder.

xcopy /e "V:\WebServer\WebServerZ\ssl\." "C:\Users\username\Desktop\Schedueled Backups\AllBackups\WebSite" /D /K /H /Y
-- This will backup the raw php/img and what is hosted on your website through your apache, this does not backup mysql db just the apache folder selected

xcopy /e "C:\Users\username\Desktop\otclient-master\." "C:\Users\Death\Desktop\Schedueled Backups\AllBackups\Client" /D /K /H /Y
-- This is to backup the custom client you have and make sure you keep a running back history and are current on it's dev being saved

xcopy /e "C:\Users\username\Desktop\Remere's Map Editor\." "C:\Users\username\Desktop\Schedueled Backups\AllBackups\RME" /D /K /H /Y
-- This is to backup RME so you do not lose any brushes ect or setting you may have customized, I made a lot of brushes for my rme and make some here and there

set year=%DATE:~10,4%
set day=%DATE:~7,2%
set mnt=%DATE:~4,2%
set hr=%TIME:~0,2%
set min=%TIME:~3,2%
-- This is used in naming uniquely the date stamped zipped file, just leave it alone. Like all lines starting in -- delete this line.

IF %day% LSS 10 SET day=0%day:~1,1%
IF %mnt% LSS 10 SET mnt=0%mnt:~1,1%
IF %hr% LSS 10 SET hr=0%hr:~1,1%
IF %min% LSS 10 SET min=0%min:~1,1%
-- This is used in naming uniquely the date stamped zipped file, just leave it alone. Like all lines starting in -- delete this line.

set backuptime=%year%-%day%-%mnt%-%hr%-%min%
echo %backuptime%
-- This is used in naming uniquely the date stamped zipped file, just leave it alone. Like all lines starting in -- delete this line.


:: SETTINGS AND PATHS
:: Note: Do not put spaces before the equal signs or variables will fail

:: Name of the database user with rights to all tables
set dbuser=PLACE A DB USERNAME LOGIN HERE THAT CAN ACCESS THE CORRECT DBS (PHPMYADMIN/SERVER DB)

:: Password for the database user
set dbpass=Password for user of DB with proper permission to do amazing things....

:: Error log path - Important in debugging your issues
set errorLogPath="C:\Users\username\Desktop\Schedueled Backups\AllBackups\DBBackupErrorLogs\dumperrors.txt"
-- set this path above to a directory you can check in via the error logging to see if things are working later if problems occur.
--Std output looks like this....
--mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (10061) when trying to connect


:: MySQL EXE Path
set mysqldumpexe="V:\WebServer\WebServer\main\mysql\bin\mysqldump.exe"
-- you will need to find your myslq dump exe file path and provide that so it can be used in this batch operation to export the DB.

:: save path
set backupfldr=C:\Users\username\Desktop\Schedueled Backups\AllBackups\
set backupfldr1=C:\Users\username\Desktop\Schedueled Backups\AllBackups\Server\
set backupfldr2=C:\Users\username\Desktop\Schedueled Backups\AllBackups\Site\
:: Path to data folder which may differ from install dir
set datafldr="V:\WebServer\webServer\core\mysql\data"
-- Above are all the paths inside the main backups directory. the structure is as such so it looks correct and clean inside the ZIP and is as nice as I could make it.
--the mysql data folder is a real folder inside the mysql installs dir, you may need to fish around a bit but it is there.

:: Path to zip executable
set zipper="C:\Users\username\Desktop\MySQLBackups\zip\7za.exe"
-- If you do not have a zip go download 7az and give this the directory! I know a pain right? well this is actually pretty damn amazing shit when it is all done so...worth it.


:: Number of days to retain .zip backup files
set retaindays=500
-- probably best to just leave alone, manually delete them if you need them gone...some day you may need them badly.
:: DONE WITH SETTINGS


--This is where the script starts to work with everything given to it, for my backups probably 400 pages of text scrolls by, pretty fun! especially automated! :D
:: GO FORTH AND BACKUP EVERYTHING!

:: Switch to the data directory to enumerate the folders
pushd %datafldr%

echo "Pass each name to mysqldump.exe and output an individual .sql file for each"

:: turn on if you are debugging
@Echo off

FOR /D %%F IN (*) DO (

IF NOT [%%F]==[performance_schema] (
SET %%F=!%%F:mad:002d=-!
%mysqldumpexe% --user=%dbuser% --password=%dbpass% --databases --routines --log-error=%errorLogPath% %%F > "%backupfldr%%%F.%backuptime%.sql"
) ELSE (
echo Skipping DB backup for performance_schema
)
)

echo "Zipping all files ending in .sql in the folder"

:: .zip option clean but not as compressed

%zipper% a -tzip "%backupfldr%FullBackup.%backuptime%.zip" "%backupfldr%*"

echo "Deleting all the files ending in .sql/zip only"
xcopy "C:\Users\username\Desktop\Schedueled Backups\AllBackups\*.zip" "C:\Users\username\Desktop\Archive\" /D /K /H /Y
xcopy "C:\Users\username\Desktop\Schedueled Backups\AllBackups\*.zip" "D:\Archive\" /D /K /H /Y
del "%backupfldr%*.sql"
del "%backupfldr%*.zip"
::return to the main script dir on end
@DEL /s /q "C:\Users\username\Desktop\Schedueled Backups\AllBackups\Site\"
@DEL /s /q "C:\Users\username\Desktop\Schedueled Backups\AllBackups\Server\"
@DEL /s /q "C:\Users\username\Desktop\Schedueled Backups\AllBackups\Client\"
@DEL /s /q "C:\Users\username\Desktop\Schedueled Backups\AllBackups\RME\"

echo "done"
popd
-- That is it! the script will leave FILE structures behind, though removing this is pretty problematic for having this work automatically. The empty dirs once done are really not an issue and should just be left alone and ignored. Anyhow ill post some pics of my backups being saved and maybe of it running.

-- This will backup if setup correctly, 2 zip files to different locations that are identical copies of, -Client - Website- Server -RME -Database

-- Hope it helps

- Death
Post automatically merged:

Notice the dates and file sizes. As the days passed and I worked on it, I did not lose the past nor the present and without any effort I was able to keep all of it. I cant count the number of times I have really screwed up something and wish I could look back at the way I had it a week or a month ago. Some problems take a long time to flush out....its nice to have the layers of protection automation grants you.

1576833686333.png
Post automatically merged:

Since the mysqlbackup.bat I provided can be executed ANY TIME BY 1 CLICK or via schedule so it is very easy to use and maintain. I honestly hope this helps some of you to maintain your hard work and effort. Best wishes to you guys and good luck out there.
Post automatically merged:

databse sql exports should maintain structure completely allowing you to go strait from a backup to php my admin, dropping the current DB and executing the sql for the backup and remaking the DB for a direct rollback to the time of the backup selected. All website data and game world data that is DB stored in the backed up dir would be restored. This should ensure that no matter how badly you or a player messes your game world up you can repair it.
 
Last edited by a moderator:
OP
Kavalor

Kavalor

(Real)Creator of ChaosOT
Joined
Dec 13, 2007
Messages
242
Best answers
0
Reaction score
42
Location
Washington State, USA
has anyone set this up? did it work? did anyone do anything with this or was it useless? Not even shit talked...feels kinda odd lol :D
 

Ochman

Advanced OT User
Joined
Feb 27, 2016
Messages
286
Best answers
3
Reaction score
177
has anyone set this up? did it work? did anyone do anything with this or was it useless? Not even shit talked...feels kinda odd lol :D
I think the biggest disadvantage of this resolution is that it's on windows. I mean, it could be potentially good to automate backups (this is what most of the hosts do anyways), but because it's on Windows, I don't think many production servers will get any advantage out of this.

Also, the server/client files saved in backup is weird thing to do. If I understand intentions correctly, we are just making what git/tfs repositories are for.

I am not saying it's bad script or that you shouldn't use it. I am saying it is good to use if you are using Windows on your server machines, but I (personally) would exclude server/client files if they are on cloud repository already.
And @Kavalor; if you're into improving this kind of a script (for external users to use), you could possible add this path as a variable, instead of having it redundant everywhere "C:\Users\username\Desktop\Schedueled Backups\AllBackups\". It would be then easier for unconscious users to use.

I really do like to automate devops jobs, so i have to say good job for writing this kind of backup script. Bonus points for selflessly sharing it.
 

Extrodus

Veteran OT User
Joined
Dec 22, 2008
Messages
2,292
Best answers
1
Reaction score
286
Location
Canada, Eh?
I think the biggest disadvantage of this resolution is that it's on windows. I mean, it could be potentially good to automate backups (this is what most of the hosts do anyways), but because it's on Windows, I don't think many production servers will get any advantage out of this.

Also, the server/client files saved in backup is weird thing to do. If I understand intentions correctly, we are just making what git/tfs repositories are for.

I am not saying it's bad script or that you shouldn't use it. I am saying it is good to use if you are using Windows on your server machines, but I (personally) would exclude server/client files if they are on cloud repository already.
And @Kavalor; if you're into improving this kind of a script (for external users to use), you could possible add this path as a variable, instead of having it redundant everywhere "C:\Users\username\Desktop\Schedueled Backups\AllBackups\". It would be then easier for unconscious users to use.

I really do like to automate devops jobs, so i have to say good job for writing this kind of backup script. Bonus points for selflessly sharing it.
Atleast now windows users have something to follow, linux has it easy lol
 
OP
Kavalor

Kavalor

(Real)Creator of ChaosOT
Joined
Dec 13, 2007
Messages
242
Best answers
0
Reaction score
42
Location
Washington State, USA
ok good replies thank you, the backing up of the client was for people who are doing a lot of client alterations/changes and need to keep the market right and changes backed up
 
Top