Jump to content

Backup on Start


ungkor

Recommended Posts

I just lost my 140+ day world due to an unexpected power-off of a pc.

 

As the game is in Alpha, I should have been backing up my saves. My bad. So I made a powershell script that will backup the save game area of 7d2d and then start the launcher. If you want to use it, you'll need to enable powershell scripts in windows

 

 

Launch powershell as administrator, then execute this:

 

Set-ExecutionPolicy RemoteSigned

 

Then open a file editor like notepad and put this in the file:

 

----

$gameData = "C:\Users\username\AppData\Roaming\7DaysToDie"

$saveDir = "C:\Users\username\AppData\Roaming\7DaysToDieBackups"

$today = (Get-Date).ToString('yyyy-MM-dd_HHmmss')

 

$location = New-Item -Path $saveDir -Type Directory -Name $today

Copy-Item -Recurse $gameData -Destination $location

 

$gameStart = "C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die\7dLauncher.exe"

$gameDir = "C:\Program Files (x86)\Steam\steamapps\common\7 Days To Die"

Start-Process -FilePath $gameStart -WorkingDirectory $gameDir

----

 

replace 'username' with whatever name you use to log into windows.

 

Then run the script. (in powershell, .\7d2die.ps1) It will copy the 7DaysToDie folder (mine is about 1 gig), naming it based on the date with minutes and seconds. So watch your hard drive space. 1gig each time can add up.

Link to comment
Share on other sites

I have a batch file running while playing that makes a backup with the timestamp of my game each 6 minutes. Needs to be placed inside the map folder you are playing. Could be changed to be placed somewhere else tho. Name of the game you want to save needs to be edited:

 

:: Back up

 

:: Set some variables

set destinationFolder=bck

set folderName="NameOfGame"

 

:loop

 

:: Check to see if the path is available

if not exist %destinationFolder% goto :nodestinationFolder

 

:: Check to see if the validation file exists

if not exist %folderName% goto :nocopyFile

 

for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set DateTime=%%a

 

set Yr=%DateTime:~0,4%

set Mon=%DateTime:~4,2%

set Day=%DateTime:~6,2%

set Hr=%DateTime:~8,2%

set Min=%DateTime:~10,2%

set Sec=%DateTime:~12,2%

 

set BackupName=%folderName%_%Yr%-%Mon%-%Day%_%Hr%%Min%%Sec%

 

:: Desktop

robocopy "%folderName%" "%destinationFolder%/%BackupName%" /e

 

@echo.

@echo Files copied. Please review output for errors.

 

timeout /t 360

goto loop

 

:nodestinationFolder

@echo The destination drive "%destinationFolder%" does not exist.

goto :nocopy

 

:nocopyFile

@echo The destination path "%folderName%" does not exist on folder %destinationFolder%.

goto :nocopy

 

:: No files have been copied

:nocopy

::@echo A valid backup location cannot be confirmed.

@echo No files have been copied.

 

:eof

@echo.

@pause

Link to comment
Share on other sites

Yes, I've got my own script running regularly backing up my game (and I move each build of the game to its own non-Steam directory to protect the game itself from updates).

 

Suxs to have to learn the lesson the hard way ungkor, but at least take satisfaction in knowing you won't ever less another game to power loss, game-breaking bug, etc etc.

Link to comment
Share on other sites

Very useful.

You might want to just target the files for the world though.

There's no need to back up the game itself, the POIs, the xml etc when you are just playing.

 

The only time you might want to do all of this is when modding.

 

C:\Users\username\AppData\Roaming\7DaysToDie\Saves\map_name\save_name

 

Down to that level? Is that is all that is needed to restore? (for a single map anyway)

Link to comment
Share on other sites

I wrote a batch file that I use for early access games that I play. I put it on my desktop and double-click it when I want to backup. I also copy the game files to a slower backup drive so I don't clog up my SSD.

 

I edited it for 7d2d and I run at the beginning of each new ingame day (since I play single player, it is not a big deal to shut down the game and restart every few hours)

 

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

 

FOR %%A IN (%Date%) DO (

FOR /F "tokens=1-3 delims=/-" %%B in ("%%~A") DO (

SET Today=%%D%%B%%C

)

)

 

FOR /F "tokens=1-3 delims=:.," %%A IN ("%Time%") DO (

SET Timenow=%%A%%B

)

 

mkdir "D:\Bubbee\7Days_Backups\%Today%%Timenow%"

 

robocopy "C:\Users\Bubbee\AppData\Roaming\7DaysToDie\Saves" "D:\Bubbee\7Days_Backups\%Today%%Timenow%" /E

Link to comment
Share on other sites

I use Second copy to copy all of my save games files to my Dropbox, it only copies files that have changed since the last copy. I have it set to run every morning at 6 AM or it can be manually run at anytime I feel the need. This allows me to play the same game on any computer I have by simply coping the saved game files to the appropriate game folder.

Link to comment
Share on other sites

C:\Users\username\AppData\Roaming\7DaysToDie\Saves\map_name\save_name

 

Down to that level? Is that is all that is needed to restore? (for a single map anyway)

 

Yes, that is what I am talking about, but for some reason I think there might be a second place that should be backed up. I could be wrong, though. Maybe I am just thinking about that worlds folder, which only makes a copy of the map for your use when starting a new game without having to do another map gen.

Somebody around here should know exactly.

 

All I know is that you shouldn't have to be duplicating gigs of data every time you start up, it's just wear and tear on your machine.

Link to comment
Share on other sites

Yes, that is what I am talking about, but for some reason I think there might be a second place that should be backed up. I could be wrong, though. Maybe I am just thinking about that worlds folder, which only makes a copy of the map for your use when starting a new game without having to do another map gen.

Somebody around here should know exactly.

 

All I know is that you shouldn't have to be duplicating gigs of data every time you start up, it's just wear and tear on your machine.

 

I have backed up and restored a few games A18 and before. You just copy what is in:

"C:\Users\Bubbee\AppData\Roaming\7DaysToDie\Saves"

 

... to a backup folder somewhere else.

 

Keep in mind that it will backup ALL of your various maps. So, if you have 4 different maps generated, it will copy all of them, each time you do a backup.... which can eat up harddrive space fairly quickly.

 

That is why I only generate one map at a time and delete any that I'm not actively using... especially since this an an Alpha+Experimental build and things can change from week to week.

 

Don't be afraid to delete all of the old maps/saves. The odds of going back to something 5 days ago is quite unlikely in this experimental build.

Link to comment
Share on other sites

I have backed up and restored a few games A18 and before. You just copy what is in:

"C:\Users\Bubbee\AppData\Roaming\7DaysToDie\Saves"

 

... to a backup folder somewhere else.

 

Keep in mind that it will backup ALL of your various maps. So, if you have 4 different maps generated, it will copy all of them, each time you do a backup.... which can eat up harddrive space fairly quickly.

 

That is why I only generate one map at a time and delete any that I'm not actively using... especially since this an an Alpha+Experimental build and things can change from week to week.

 

Don't be afraid to delete all of the old maps/saves. The odds of going back to something 5 days ago is quite unlikely in this experimental build.

 

Thanks for confirming the location.

Yeah, I suppose it could eat up space, but it sure beats backing up the entire game folder, like some people are doing.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...