Guest User

Ark Server Backup

a guest
Jan 26th, 2016
1,386
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # IdiotsInc Ark Server Backup Script
  2. # Written by @Zebwen - 26-01-2016
  3.  
  4. # Gets the current date and time and formats it nicely so we can name the output file at the end.
  5. $backuptime = Get-Date -Format "yyyy-M-d-(HH.mm)"
  6.  
  7. # Sets the location to copy the raw saved files to.
  8. $backuplocation = "C:\Ark\Backups\YourServer"
  9.  
  10. # Sets the location of the Ark save folder you want to back up.
  11. $arksavefolder = "C:\Ark\ArkData\YourServer-Data\ShooterGame\Saved"
  12.  
  13. # Sets the location of the Ark profiles folder you want to back up.
  14. # This is the profile for Ark Server Manager. Comment this line out if you do not use this tool.
  15. $arkprofilefolder = "C:\Ark\ArkData\Profiles"
  16.  
  17. # Sets the location of the off-server network share to copy the final zip file to.
  18. $networkcopylocation = "\\server-pc\arkshare"
  19.  
  20. # Do a raw copy of the current save files to the backup location.
  21. Copy-Item $arksavefolder "$backuplocation\Saved\" -Recurse
  22. Copy-Item $arkprofilefolder "$backuplocation\Profiles\" -Recurse
  23.  
  24. # Funny looking bit of code that zips up the folders we just copied.
  25. [Reflection.Assembly]::LoadWithPartialName( "System.IO.Compression.FileSystem" )
  26. $destfile = "C:\Ark\Backups\$backuptime-ArkServerBackup.zip"
  27. $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
  28. $includebasedir = $false
  29. [System.IO.Compression.ZipFile]::CreateFromDirectory("$backuplocation",$destfile,$compressionLevel, $includebasedir )
  30.  
  31. # Copies the zip file to the network location.
  32. Copy-Item $destfile $networkcopylocation
  33.  
  34. # Deletes the temporary files from the backup location now they have been copied to the network share.
  35. Remove-Item "$backuplocation\Saved\" -Recurse
  36. Remove-Item "$backuplocation\Profiles\" -Recurse
  37.  
  38. # Un-comment the below line to also remove the zip file. Going to keep this on the server for now though.
  39. #Remove-Item $destfile
Advertisement
Add Comment
Please, Sign In to add comment