Advertisement
ForeverZer0

[RMXP][RMVX] Data Backup Utility

Apr 15th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.58 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # Data Backup Utility
  3. # Author: ForeverZer0
  4. # Date: 4.15.2012
  5. # Version: 1.0
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  7. #
  8. # Explanation:
  9. #   Simple script for creating backups of your game each time the game is ran
  10. #   in debug mode. Its runs very quickly and there is practically no slowdown,
  11. #   even with large games.
  12. #
  13. # Features:
  14. #   - Backups your Data folder automatically each debug run
  15. #   - Configurable number of backups
  16. #   - Runs on a separate thread and invokes system functions for the actual
  17. #     processing to prevent any slowdown
  18. #
  19. # Instructions:
  20. #   - Place script anywhere above "Main"
  21. #   - Configure the number of backups you would like to keep.
  22. #   - Backups will be stored in the "Backups" folder in the main game directory,
  23. #     and are always listed in order of newest to oldest
  24. #
  25. # Credit/Thanks:
  26. #   - ForeverZer0, for the script
  27. #
  28. # Authors Notes:
  29. #   - Please report any bugs issues at www.chaos-project.com
  30. #
  31. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  32.  
  33. module Backup
  34.  
  35.   MAX_BACKUPS = 10
  36.  
  37.   def self.create
  38.     system("rd /s/q \"Backups\\Backup #{MAX_BACKUPS}\"")
  39.     (1...MAX_BACKUPS).to_a.reverse.each {|i|
  40.       dir_name = "Backups/Backup #{i}"
  41.       Dir.mkdir(dir_name) unless File.directory?(dir_name)
  42.       File.rename(dir_name, "Backups/Backup #{i + 1}")
  43.     }
  44.     system('xcopy Data "Backups\\Backup 1" /Y/D/I')
  45.   end
  46. end
  47.  
  48. if $DEBUG
  49.   Thread.new { Backup.create }
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement