Jump to content

Simple Database backup


5nine

Recommended Posts

I created this because i wanted an easier alternative to the log-rotator.cmd included with epoch. I also dont want to rotate my logs everytime i do a database backup. 

 

This creates a backup of your dump.rdb (your database) and sorts it in a folder named YEAR-MONTH (e.g. 2014-12). the actual filename also gets a date and timestamp like "Epoch-20141230_2205.rdb". So by using this you will get your backups nice and sorted with a folder for every month of the year. 

 

Step 1:

create a batch file inside your C:\-arma3 server path-\DB folder (where redis-server.exe is located)and name it backup.cmd. Insert the code below: 

::::::::::::::Created by Fivenine @ NibbleGaming.tk::::::::::::::

:::::::::::::: CONFIG ::::::::::::::::::

:::: Set your Arma3 Server base installation directory below.
set arma3srvpath=C:\YOUR ARMA 3\SERVER FOLDER\HERE

:::: Set your Redis Password and IP below (found inside Redis.conf)
set Redispass=ChangeMe
set RedisIP=127.0.0.1

::::::::::: ADVANCED CONFIG ::::::::::::
:: Don't touch anything below this point unless you know what your doing.
::::::::::::::::::::::::::::::::::::::::
:: Set Time and Date
SET _CUR_DATE=%DATE%
SET _CUR_TIME=%TIME%
::Setting date
FOR /F "tokens=1-4 delims=/.- " %%a IN ("%_CUR_DATE%") DO SET MONTH=%%b
FOR /F "tokens=1-4 delims=/.- " %%a IN ("%_CUR_DATE%") DO SET DAY=%%c
FOR /F "tokens=1-4 delims=/.- " %%a IN ("%_CUR_DATE%") DO SET YEAR=%%a
:: Setting Time
FOR /F "tokens=1-4 delims=:." %%a IN ("%_CUR_TIME%") DO SET HOUR=%%a
FOR /F "tokens=1-4 delims=:." %%a IN ("%_CUR_TIME%") DO SET MINUTE=%%b
SET FOLDER_NAME=%YEAR%-%MONTH%
SET BACKUP_FILE=Epoch-%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%.rdb

:: Forcesave Redis Database
redis-cli -h %RedisIP% -a %Redispass% save

::create folders
if exist "%arma3srvpath%\DBbackups" goto createYDfolder
mkdir "%arma3srvpath%\DBbackups"
:createYDfolder
if exist "%arma3srvpath%\DBbackups\%FOLDER_NAME%" goto startbackup
mkdir "%arma3srvpath%\DBbackups\%FOLDER_NAME%"

:startbackup
copy "%arma3srvpath%\DB\dump.rdb" "%arma3srvpath%\DBbackups\%FOLDER_NAME%\%BACKUP_FILE%"
:: Done

exit

step 2:

Download Redis from here https://raw.github.com/mythz/redis-windows/master/downloads/redis64-latest.zip and copy redis-cli.exe from inside that .zip to your DB folder. 

 

step 3:

Done!

 

Now just run backup.cmd to perform your backup. I include it in my restart procedure using simple batch files. You can also schedule it to run using windows task scheduler or whatever suits you best. 

 

 

 

Having problems?

I'm not sure if this works with every time and dateformat. So depending on where you live you might get a weird date and time format on your folders and files. If you do, simply create a batch file, call it timetest.cmd and insert this:

@echo off
echo %DATE%
echo %TIME%
timeout 120

Run that batch file and then copy paste the output here and i'll help you out. 

Link to comment
Share on other sites

this worked like a charm for me but can I just ask, how do you go about restoring the backup, still new at the DB side of things

rename the backup you want to dump.rdb, copy and replace  it in your DB folder while your redis server is shut down. 

Link to comment
Share on other sites

  • 2 months later...
  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...