Backup System

Backup System
by .:Fênix:.


Description

Makes a copy of your game's folders

Compability

RPG Maker XP and RPG Maker VX

Script

  1. #===============================================================================
  2. # * Backup System
  3. #-------------------------------------------------------------------------------
  4. #   - Version: 2.0
  5. #   - Date   : 21 / 08 / 2011
  6. #   - Author : .:Fênix:.
  7. #   - MSN    : [email hidden]
  8. #-------------------------------------------------------------------------------
  9. #   - Description:
  10. #     Makes a copy of your game's folders
  11. #-------------------------------------------------------------------------------
  12. #   - Compability:
  13. #     RPG Maker XP and RPG Maker VX
  14. #===============================================================================
  15.  
  16. module Backup_System
  17.   # Activate the script? (true / false)
  18.   Activate = true
  19.   # Copy Audio folder? (true / false)
  20.   Audio = false
  21.   # Copy Data folder? (true / false)
  22.   Data = true
  23.   # Copy Graphics folder? (true / false)
  24.   Graphics = false
  25.   # Seconds to make a new copy (if you set this 0, it will make
  26.   # a copy every time you run the game)
  27.   Time = 3600
  28. end
  29.  
  30. if (Backup_System::Activate)
  31.  
  32.   $VX ||= defined?(Graphics.wait)
  33.  
  34.   if (File.file?("Game.rgss#{$VX ? '2a' : 'ad'}"))
  35.     Thread.new {system("rd Backup /s /q")} if (File.directory?("Backup"))
  36.     File.delete("Backup.time") if (File.file?("Backup.time"))
  37.   else
  38.     if (($DEBUG) || ($TEST))
  39.       time = Time.now
  40.       if ((!File.file?("Backup.time")) || ((time - load_data("Backup.time")) >= Backup_System::Time))
  41.         baseDir = ""
  42.         for subDir in ["Backup/", "#{time.year}-#{time.month}-#{time.day}/", "#{time.hour}.#{time.min}.#{time.sec}/"]
  43.           baseDir += subDir
  44.           Dir.mkdir(baseDir) unless (File.directory?(baseDir))
  45.         end
  46.         for subDir in ["Audio", "Data", "Graphics"]
  47.           next unless (eval("Backup_System::#{subDir}"))
  48.           dir = baseDir + subDir
  49.           Dir.mkdir(dir) unless (File.directory?(dir))
  50.           Thread.new {system("xcopy #{subDir}" + ' "' + dir.gsub!("/", "\\") + '" /e /c /q /r /y')}
  51.         end
  52.         save_data(time, "Backup.time")
  53.       end
  54.     end
  55.   end
  56.  
  57. end
Expand to see the code.
This is amazing!
This is truely amazing, I have to agree with Juan. Not only do you not have to manually do it but this script allows you to automatically re-backup your files at the customized time. This will be really helpful for me, thanks :)
Only one slight problem. :3 While its a nice script and a nice idea and very very helpful, you'll most likely get a Script is Hanging error for the fact that Graphics.update needs to be called and if it doesn't get called within 10 seconds, it'll hang and close. So just add a Graphics.update in your for loops and it should be ok. Again nice script, not trying to dis your script or anything. xD
Actually it doesn't need Graphics.update, because I'm using Thread. I've tested this script with a 40mb project, and there was no lag to initialize the game. :D

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=75411