Jump to content
  • 0

FAQ: How to make backups of your Redis database


nedfox

Question

So you want backups of your database ? Yes, of course !

The output is pretty small, don't be afraid , they are not 8Gb dumps every time, but really, really small.

 

Quick and dirty, not too much explanation needed, so here are the 2 batch files you need :

 

1] Get redis-cli.exe (provided in the redis distribution ZIP). Place it in the same folder as redis-server.exe

 

2] Create a batchfile in the DB folder (by default "C:\Program Files (x86)\Steam\SteamApps\common\Arma 3\DB") called rdate.cmd. Copy the following text in it and save.

@echo off
rem *******************************************************************
rem
rem Set environment variables with date/time information.
rem
rem DT_MONTH .................... Two digit month
rem DT_DAY ...................... Two digit day
rem DT_YEAR ..................... Four digit year
rem DT_HOUR ..................... Two digit hour
rem DT_MINUTE ................... Two digit minute
rem DT_SECOND ................... Two digit second
rem DT_RFC ...................... YYYYMMDDTHHMMSS
rem
rem *******************************************************************
rem Grab date and time values for conversion.
SET _CUR_DATE=%DATE%
SET _CUR_TIME=%TIME%
FOR /F "tokens=1-4 delims=/.- " %%a IN ("%_CUR_DATE%") DO SET DT_MONTH=%%b
FOR /F "tokens=1-4 delims=/.- " %%a IN ("%_CUR_DATE%") DO SET DT_DAY=%%c
FOR /F "tokens=1-4 delims=/.- " %%a IN ("%_CUR_DATE%") DO SET DT_YEAR=%%d
rem Convert from "11:40:12.82" to individual parts by using a DOS FOR loop.
FOR /F "tokens=1-4 delims=:." %%a IN ("%_CUR_TIME%") DO SET DT_HOUR=%%a
FOR /F "tokens=1-4 delims=:." %%a IN ("%_CUR_TIME%") DO SET DT_MINUTE=%%b
FOR /F "tokens=1-4 delims=:." %%a IN ("%_CUR_TIME%") DO SET DT_SECOND=%%c
SET DT_RFC=%YEAR%%MONTH%%DAY%T%HOUR%%MINUTE%%SECOND%

3] Create a batchfile in the same folder called backup.cmd and paste the following code in.

@echo off
rem If you want to skip backups, delete the REM at the next line
rem goto notthistime

C:
cd "C:\Program Files (x86)\Steam\SteamApps\common\Arma 3\DB"
call rdate.cmd
SET YEAR=%DT_YEAR%
SET MONTH=%DT_MONTH%
SET DAY=%DT_DAY%
SET HOUR=%DT_HOUR%
SET MINUTE=%DT_MINUTE%
SET SECOND=%DT_SECOND%
SET BACKUP_FILE=Epoch-%YEAR%-%MONTH%-%DAY%-%HOUR%.rdb
rem redis-cli.exe is in the ZIP file obtained from the Redis site.
del dump.rdb /y
redis-cli -a <YOURREDISPASSWORDHERE> save
rename dump.rdb %BACKUP_FILE%
rem the next line copies the DB to a different location for safe keeping.
rem xcopy %BACKUP_FILE% <safe backuplocation>
rem then also unremark next line to delete the dumpfile from the dabatase folder.
rem del %BACKUP_FILE% /y
:notthistime

To manually perform a backup, just start the backup.cmd and after dumping it will rename the output to a file named Epoch-year-month-day-hour.rdb

If you want, remove some remarks to copy the created file to another location on your network and delete the dumpfile.

 

To schedule it :

If you have command prompt access , execute these commands elevated (Execute as Administrator) :

 

cmd.exe (run as admin!)

schtasks /create /tn "redis Backup" /tr "C:\Program Files (x86)\Steam\SteamApps\common\Arma3\DB\backup.cmd" /sc hourly /st 00:00

If you do not have access to the command prompt, find your way to the scheduler and put them in at your required times.

It also gives you the options to run the tasks Interactive, which will have a visible command window on your desktop.. The commands from the stuff above exectutes the tasks invisible !!

 

 

----------------

To restore (and correct me if I'm wrong, it looks plain and simple) :

 

Stop Redis, delete dump.rdb , copy the desired backupfile back to the DB folder and rename it to dump.rbd, restart Redis, done !

----------------

 

 

----------------

Redis makes a dump.rdb itself once every xx minutes, but this methode forces a timed backup of the exact time you want.

----------------

 

 

Have fun,

 

NedFox [TZW]

 

 

TimeZone Warriors/GOB Server : 80.60.255.84:2324

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

  • 0

LOL, ok completely missed that line. So log-rotate.cmd in the tools folder does the same and more, although I would prefer to not have hourly log rotations, so at least I didn't do it invain :P

I call log-rotation once a day, and db backups every hour.

Link to comment
Share on other sites

  • 0

The log rotator.cmd saves your DB file (current state) to a folder SC\RotatedLogs\<timestamp>

 

So every time you run logrotator.cmd it saves your DB there, which can be put back in your \DB folder to restore Redis.

 

I run logrotator once a day (with the AT.exe command) , but it's easy to put it in your normal batch file restarting your server , so you get 3-4 hour backups.

Link to comment
Share on other sites

  • 0

The log rotator.cmd saves your DB file (current state) to a folder SC\RotatedLogs\<timestamp>

 

So every time you run logrotator.cmd it saves your DB there, which can be put back in your \DB folder to restore Redis.

 

I run logrotator once a day (with the AT.exe command) , but it's easy to put it in your normal batch file restarting your server , so you get 3-4 hour backups.

Thank you. I will try to do.

And how to make preserved in another place, and not in the folder with the server.

Link to comment
Share on other sites

  • 0

look here in the logrotator.cmd : 

 

copy "%arma3srvpath%\DB\dump.rdb" "%arma3srvpath%\DBbackups\RotatedLogs\%dtStamp%\DBbackups\dump.rdb"

 

If you want to copy it to another folder, create that folder (like C:\YOURPATH) and then :

 

Put this RIGHT BELOW THAT LINE.

 

md "C:\YOURPATH\%dtStamp%"

xcopy "%arma3srvpath%\DB\dump.rdb"  "C:\YOURPATH\%dtStamp%\dump.rdb"

 

This will copy the DB to your specified folder, making a timestamp folder and put the DB in there.

Link to comment
Share on other sites

  • 0

look here in the logrotator.cmd : 

 

copy "%arma3srvpath%\DB\dump.rdb" "%arma3srvpath%\DBbackups\RotatedLogs\%dtStamp%\DBbackups\dump.rdb"

 

If you want to copy it to another folder, create that folder (like C:\YOURPATH) and then :

 

Put this RIGHT BELOW THAT LINE.

 

md "C:\YOURPATH\%dtStamp%"

xcopy "%arma3srvpath%\DB\dump.rdb"  "C:\YOURPATH\%dtStamp%\dump.rdb"

 

This will copy the DB to your specified folder, making a timestamp folder and put the DB in there.

Thank you very much!.

Link to comment
Share on other sites

  • 0

Hi, anyone know how to change the standard epoch log rotator so it names the folders correctly for english Uk regional settings? Currently it's like this:

:: Set Time and Date
SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%_%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%_%time:~6,2%
::Make Date Stamp
if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)
ECHO Todays Date and time (%date%)(%time%) / %dtStamp%
if %debug% == 1 (
timeout %dbsecs%
)

But, that means all the dates and times of the folders are messed up for me... 

 

Thanks for any help :)

Link to comment
Share on other sites

  • 0

Ah didn't realize :)

 

Since I don't use the stuff from the supplied batchfile I didn't see it's a bug in the code.

 

20140-2-_0200_07   is just wrong generated.

 

Post a screenshot in the BUG section, title it "Log Rotator Folder naming Bug" and VBAWol will pick it up.

Link to comment
Share on other sites

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
  • Advertisement
  • Discord

×
×
  • Create New...