Save-Point
Backup Specific Files - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker VX/VXAce (RGSS2/3) Engines (https://www.save-point.org/forum-117.html)
+---- Thread: Backup Specific Files (/thread-5386.html)



Backup Specific Files - Mintyy - 02-16-2015

Backup Specific Files
Author: Soulpour777
February 16, 2015

Description:
This script allows you to backup specific files by using source and destination by FileUtils module. The reason why it is a specific backup is because it can be used to duplicate a file prior to saving and saving.


Requirements: This needs the FileUtils Module written by Minero Aoki.

You can access this module in this location:
https://raw.githubus...ib/fileutils.rb


Instructions:

To backup all your specific files, do this on a script call:

backup_listed_files

The backup files are located on the Game Folder, in a folder named "Backup".


Screenshot:
[Image: 8BjOUPu.jpg]

Script Download:

Code:
#==============================================================================
# ** Backup Specific Files
# Author: Soulpour777
# February 16, 2015
#------------------------------------------------------------------------------
# Description: This script allows you to backup specific files by using source
# and destination by FileUtils module. The reason why it is a specific backup
# is because it can be used to duplicate a file prior to saving and saving.
#------------------------------------------------------------------------------
# Requirements: This needs the FileUtils Module written by Minero Aoki.
# You can access this module in this location:
# https://raw.githubusercontent.com/sj26/ruby-1.9.3-p0/master/lib/fileutils.rb
#------------------------------------------------------------------------------
# Instructions:
# To backup all your specific files, do this on a script call:
# backup_listed_files
#------------------------------------------------------------------------------
# The backup files are located on the Game Folder, in a folder named "Backup".
#==============================================================================

module Soul
  module Files_Backup
    # Specified files to backup. Why specify? Because I want to make it
    # a script where you want to backup what you want, not what the script
    # permanently dictates. I want to make it flexible as possible.
    Files = ["Actors.rvdata2", "Animations.rvdata2", "Armors.rvdata2",
    "Classes.rvdata2", "CommonEvents.rvdata2", "Enemies.rvdata2",
    "Items.rvdata2", "Scripts.rvdata2", "Skills.rvdata2",
    "States.rvdata2", "States.rvdata2", "System.rvdata2", "Tilesets.rvdata2",
    "Troops.rvdata2", "Weapons.rvdata2", "MapInfos.rvdata2"]
    Map_Number = ["Map001.rvdata2"] # no maps to backup, add map numbers you want to backup.
    # For example: map_Number = ["Map001.rvdata2"]
  end
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * copy_with_path (New Function) - this duplicates the source and puts
  # it into a new destination. You can use this to back up your files right
  # before you save it. So when you have an item existent or non existent
  # prior of that saving, you will still have it.
  #--------------------------------------------------------------------------
  def copy_with_path(src, dst)
    FileUtils.mkdir_p(File.dirname(dst))
    FileUtils.cp(src, dst)
  end

  def backup_listed_files
    Soul::Files_Backup::Files.each do |files_to_backup|
      copy_with_path("Data/#{files_to_backup}","Backup/#{files_to_backup}")
    end
    Soul::Files_Backup::Map_Number.each do |maps_to_backup|
      copy_with_path("Data/#{maps_to_backup}","Backup/#{maps_to_backup}")
    end   
  end
end

Author's Notes:

Why specific? Why not backup all? Note that this script is for people who want to do specific backups for their files. Say for example you only want to backup a certain saved file prior in a future save, you can copy / backup it and put it on a sample folder called backup.