ParanoiaPhD

Member
I wanted to make sure I had backups to ensure my server isn't easily killed some how. I was imagining a way and did some searches and ran across a few scripts. I found one script that actually works like a charm but it always triggers error message BUT it is actually working. SO THE IDEA is to have the bat compress the "Backups" folder and save the compressed folder into Dropbox folder... Free and super easy! You could also use one drive but I think the dropbox method uses less resources. The folder it creates is named the number of the day of the machine and the compressed file inside (mine went from 180mb to 24mb) gets a random name. Not sure if the files will be able to overlap or if they will need removal from the drive once a month but anyways this method works!!! Here is the script I used and all you have to do is make the script an automated daily task.

C#:
@echo off
@title=Folder zip and move...

rem Parameters
  rem Folder to zip and move
    set PARENT_FOLDERTOZIP=C:\Users\maste\OneDrive\Desktop
    set FOLDERTOZIP=p95v294b8.win64

  rem Target folder for moving the input folder to.
    set FOLDERTARGETLOCATION=C:\Users\maste\OneDrive\Desktop\backuptest

  rem Where to place compressed folders
    set ZIPDIR=C:\Users\maste\OneDrive\Desktop\backuptest


rem Configuration
  set SEVENZIP_EXE=C:\Program Files\7-Zip\7z.exe


rem =================== Date ==============================================
rem There is no universal way inside batch itself to get a
rem date that is independent of regional settings (but is
rem quite trivial if an external program or script
rem (Perl/Python) is available).
rem
rem For short date formats:
rem
rem   -------------------------------------------------------
rem
rem   ISO-8601:
rem     0123456789
rem     yyyy-MM-dd/     E.g.: 2009-09-24
rem
rem     set FDATE=%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%
rem
rem   -------------------------------------------------------
rem
rem   Central european:
rem     0123456789
rem     dd/MM/yyyy     E.g.: 24/09/2009
rem
rem     set FDATE=%DATE:~6,4%%DATE:~3,2%%DATE:~0,2%
rem
rem   -------------------------------------------------------
rem
rem   US:
rem
rem     0123456789
rem     MM/dd/yyyy     E.g.: 09/24/2009
rem
rem     set FDATE=%DATE:~6,4%%DATE:~0,2%%DATE:~3,2%

set FDATE=%DATE:~6,4%%DATE:~0,2%%DATE:~3,2%
set ZIPFILE=%ZIPDIR%\%FDATE%.7z

set FOLDERTOZIP_FULLPATH=%PARENT_FOLDERTOZIP%\%FOLDERTOZIP%
mkdir %FOLDERTARGETLOCATION%


rem Does a zip file already exist?
if exist "%ZIPFILE%" GOTO L_ZIPFILE_EXISTS
GOTO L_ZIPFILENAME_OK


rem Find a compressed file that does not already exist.
:L_ZIPFILE_EXISTS
set RNUM=0
:L_TRYANOTHER
set /a RNUM=%RNUM% + 1
set ZIPFILE=%ZIPDIR%\%FDATE%-%RNUM%.7z
echo Candidate: %ZIPFILE% ...
if exist "%ZIPFILE%" GOTO L_TRYANOTHER


rem Zip the folder!
:L_ZIPFILENAME_OK
"%SEVENZIP_EXE%"  a %ZIPFILE%   "%FOLDERTOZIP_FULLPATH%"

if exist "%ZIPFILE%" GOTO L_OKZIP
GOTO L_ERROREND


:L_OKZIP
rem Move folder: copy, then delete source.
set DEST_FOLDER=%FOLDERTARGETLOCATION%\%FOLDERTOZIP%
mkdir "%DEST_FOLDER%"
xcopy /Y /S "%FOLDERTOZIP_FULLPATH%"\*.*   "%DEST_FOLDER%"\
rmdir /S "%FOLDERTOZIP_FULLPATH%"
GOTO L_END


:L_ERROREND
echo 7-Zipping failed !!!


:L_END

pause
 
I did a similar thing. I have it backing up the main server saves, the local game wiki and the couple Centred server files. It kills the tasks, backs up everything to Dropbox and restarts the centred servers.
 
oh yeah that's a possibility too. to kill the task means you want to back up more than just the backup files. I tried backing up the whole server while it's running and ran into all kinds of files still in use and some would not even copy. Task scheduler could easily be set up to kill the server and back it all up then start the server again after. Like a razor macro you just need to optimize the timers and adjust for greater and greater server files sizes so 60 seconds extra would probably work for a long time.

Right now I do manual backups of the whole server only before and after I make big updates to scripts and what not as those things are not contained in the save folder which is what the backups folder contains. The saves folder is where more sensitive files are contained so for example if something in there get corrupted then the server is screwed forever as it contains a lot of gibberish that you cant make sense of and it's impossible to repair. It's essentially where all of the player accounts, house, banks, inventories, pets, ect are contained and is therefor the most important to backup.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back