Announcement

Collapse
No announcement yet.

Backup on Start

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Backup on Start

    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\7DaysToDieBacku ps"
    $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.
    Last edited by ungkor; 10-22-2019, 06:41 AM.

    #2
    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.

    Comment


      #3
      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
      Last edited by Kalarro; 10-22-2019, 09:52 PM.

      Comment


        #4
        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.

        Comment


          #5
          Originally posted by AtomicUs5000 View Post
          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)

          Comment


            #6
            Duplicati is cool, and you can do incremental backups with it.

            Comment


              #7
              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\Sa ves" "D:\Bubbee\7Days_Backups\%Today%%Timenow%" /E

              Comment


                #8
                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.

                Comment


                  #9
                  Originally posted by seagas View Post
                  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.
                  Nice idea

                  Comment


                    #10
                    Originally posted by ungkor View Post
                    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.

                    Comment


                      #11
                      Originally posted by AtomicUs5000 View Post
                      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\Sa ves"

                      ... 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.

                      Comment


                        #12
                        Originally posted by Bubbeenator View Post
                        I have backed up and restored a few games A18 and before. You just copy what is in:
                        "C:\Users\Bubbee\AppData\Roaming\7DaysToDie\Sa ves"

                        ... 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.

                        Comment


                          #13
                          I'm gonna start doing this. It's really painful to lose a game you're invested in.

                          Comment

                          Working...
                          X