EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   Automatic compressed mysql backups using batch file and windows task scheduler (https://www.eqemulator.org/forums/showthread.php?t=42095)

irongut_av 09-21-2018 11:11 AM

Automatic compressed mysql backups using batch file and windows task scheduler
 
If you do not have an automated MySQL backup on windows and would like to set them up, here is a good starting point:


Create a batch file (example: db_backup.bat) and open it up in your favorite editor. Paste the following contents below, replacing the directory structure, dbname, user and password as needed.
Code:

@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"

"C:\Program Files\MariaDB 10.0\bin\mysqldump.exe" -uroot -ppassword peq > C:\eqemu\backups\peq_%fullstamp%.sql

"C:\Program Files (x86)\WinRAR\rar.exe" a -df C:\eqemu\backups\peq_%fullstamp%.rar C:\eqemu\backups\peq_%fullstamp%.sql

Save the file and test it. If the directory location is correct, as well as your MySQL credentials, you should have a compressed backup of your database in the EQEMU/backups folder. Note: the .sql file generated by the MySQL dump will be deleted after being compressed because of the -df option for rar.exe

Next, open up the windows task scheduler and create a new task that calls this batch file. Set the schedule preference (daily, hourly, etc) and starting time.

Akkadius 09-21-2018 03:06 PM

Just FYI

Code:

perl eqemu_server.pl backup_database_compressed
Will do the same thing for you

https://github.com/EQEmu/Server/wiki...nance-commands

irongut_av 09-21-2018 04:01 PM

Thanks, that's makes things even easier. :grin:


All times are GMT -4. The time now is 08:53 PM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.