Jump to content

Redis Backup with batch - simple


darthmard

Recommended Posts

I put together some code for a simple Redis backup for command I use it myself in a windows task simple to use for new server owners who like to use batch files.

I know there's programs for this but I like to use batch files if done right uses less resources on server.

 

Make a batch file (Backup.bat) or use in own restart batch if have one.

@echo off
color 0A
echo Running Redis Database Backup..
echo.
echo.
IF Not EXIST C:\Database\dump.rdb GOTO DoNothing
if not exist "C:\Database\backup" mkdir C:\Database\backup
:: above checks for folders and file
::
:: DO NOT EDIT
for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd=%%k%%i%%j
echo Date: %yyyymmdd%
for /F "tokens=1-2 delims=: " %%l in ('time /t') do set hhmm=%%l%%m
echo Time: %hhmm%
:: END NO EDIT
::
copy C:\Database\dump.rdb C:\Database\backup\dump.rdb
::
REN C:\Database\backup\dump.rdb dump_%yyyymmdd%_%hhmm%.rdb
echo.
echo Backup was successfully completed!
timeout 10
::
:: You can add database startup here if you want
:: START redis-server.exe redis.conf
:: echo Database started successfully!
::timout 10
exit

This code will save DBdump.rdb and move to backup and rename it this example: dump_20150207_0201.rdb

 

NOTE: I have my redis in c:\database you can edit this in batch code

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks 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...