7 Days to Die

7 Days to Die

Not enough ratings
Auto Backup of Game
By r4z0r84
Automatically backup your save game daily and remove old saves after they're 7 days old
   
Award
Favorite
Favorited
Unfavorite
7DaysToBackup Full guide.
First off I've made this guide as there are multiple bug reports that people have lost their entire progress or entire base etc, This is the best thing to combat that within the beta stage as you can always revert to a previous day before everything went wrong.

Script
First off right click somewhere (I made this on the desktop) select New>Text Document
This will make a new text document on your desktop, double click it and your text editor will open most likely Notepad
copy and paste then edit the code below noting that you replace %username% with your username on your computer, this is handy if the scheduled task is running as a different user than the game saves are located in, you can probably leave it as %username% if you only have one user on your computer.

Also if you have a different backup path or only have one drive make sure to change it from D:\ to something else.
xcopy "C:\Users\%username%\AppData\Roaming\7DaysToDie" "D:\7DaystoDieBackup\%date%\" /s /e /c forfiles -p "D:\7DaystoDieBackup" -d -7 -c "cmd /c IF @isdir == TRUE rd /S /Q @path"
Once you have it how you want it select File>Save As and select All Files instead of .txt and call it 7DaysToBackup.bat this will change the file type to a batch script.

For more info on what each line does, xcopy copies from "source" to "destination" and %date% adds folders for the current date so you know what day each of the backups are from.
forfiles checks how old the folder is as its got the @isdir == TRUE so it won't delete subfiles/folders it will only delete from within your backup directory, the -d -7 is how old the backup must be before it is deleted, you can change this to whatever value you want just make sure that you have enough space to support the amount of copies you require.

Schedule a Task
push your windows key or click start and search for "Task Scheduler"
up the top right there will be "Create Basic Task" click it.
The "Create Basic Task Wizard" will pop open
Give your task a reasonable name such as 7DaysToBackup
Click Next
Daily
Click Next
Set a different time if you desire, if your running the game on a sever anytime is fine, if you're running it on your own computer make sure its a time that your computer will be powered on.
Click Next
Start a Program
Click Next
Browse for the 7DaysToBackup.bat file you created earlier
Click Next
Click Finish

And you're done, you will now automatically backup your save game every day and when a save is older than 7 days it will be deleted.

8 Comments
Obsessive Compulsive Feb 14, 2021 @ 7:29am 
If you prefer the robo method, here are some helpful things you can do with the code for compression and clean up while checking it is running. I put it on as an auto task within windows. Very simple .bat file but powerful what it was doing. Really bottle necked our servers tho. I dont know of any cpu or thread handling with that operation but if you can find a way, that would improve the lag for you. It would take much longer to achieve tho
Obsessive Compulsive Feb 14, 2021 @ 7:27am 
:Live
echo Live server found. Starting backup process.

echo d | robocopy "C:\7 Days Worlds\YourWorld" "F:\Backup\YourWorld\%dateStampALT%\%dateTimeStamp%" /eta /e /mt:2 /R:2 /W:3 /Z /NP /NDL

echo Copy of data complete.

::echo Attempting to compress latest data...

::Compress
::cd C:\Program Files\7-Zip
::7z a -t7z "D:\Backup\YourWorld\Compressed1\%datestamp%" "D:\Backup\YourWorld" -mx0

::echo Compression completed.

echo Cleaning out old data backups over 3 days in age.

forfiles /p "F:\Backup\YourWorld" /d -3 /c "cmd /c if @isdir==TRUE del /s /q @path"
forfiles /p "F:\Backup\YourWorld" /d -3 /c "cmd /c if @isdir==TRUE rd /s /q @path"

echo Cleanup finished.
echo Closing program.

:EndProg
exit
Obsessive Compulsive Feb 14, 2021 @ 7:27am 
@echo off

echo 7D2D server check and auto restart...
echo Setting date and time stamps...

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 "dateTimeStamp=%YY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
set "dateStampALT=%YY%-%MM%-%DD%"

echo Timestamp set.
echo Checking for live 7D2D server.

tasklist /FI "IMAGENAME eq 7DaysToDieServer.exe" 2>NUL | find /I /N "7DaysToDieServer.exe">NUL
if "%ERRORLEVEL%"=="0" goto Live

echo No live server found. Checking for live server in 60 seconds.
Timeout 60

tasklist /FI "IMAGENAME eq 7DaysToDieServer.exe" 2>NUL | find /I /N "7DaysToDieServer.exe">NUL
if "%ERRORLEVEL%"=="0" goto Live

echo No live server found. Closing program.

goto EndProg
Obsessive Compulsive Feb 14, 2021 @ 7:23am 
Try ST out again. It has had lots of updates since then. The auto backup was having issues at first but no reports for a long time. It is MUCH faster than a robocopy and less resource intensive. It also removes old backups for you to keep a limited number for space. If you have issues with it tho, let me know
r4z0r84  [author] Feb 8, 2021 @ 9:54pm 
Yeah you can also use robocopy which is less resource intensive or fastcopy(additional software but highly customisable), so it doesn't override the same file with the same file to make it faster etc but most items are dynamic and new regardless. servertools didn't seem to work for me last time i tried it in 2019 thats one of the only reasons i made this guide to begin with :)
Dizor Feb 7, 2021 @ 9:22am 
I would prefer to use 7D2D-Backupper [github.com] script.
F5 - backup latest played game.
F9 - restore latest backup.
r4z0r84  [author] Jun 12, 2020 @ 1:03am 
I only use SSD's on my server's these days with them being so cheap so players don't even notice XD
Obsessive Compulsive Jun 11, 2020 @ 6:23pm 
This works, however xcopy is a heavy transfer over and will chew up a hard drive and push your cpu usage way up. SSD may handle it better but likely still hurts a busy server. You can reduce the load slightly but it still kills the data transfer making most servers bottleneck during the save. ServerTools has a backup option as one of the tools offered. It also compresses the data for you reducing the backup of large worlds