Parent

Included Modules

Class/Module Index [+]

Quicksearch

Backup::CLI::Utility

Public Instance Methods

-v click to toggle source
Version

Returns the current version of the Backup gem

# File lib/backup/cli/utility.rb, line 235
map '-v' => :version
decrypt click to toggle source
Decrypt

Shorthand for decrypting encrypted files

# File lib/backup/cli/utility.rb, line 164
desc 'decrypt', 'Decrypts encrypted files'
dependencies click to toggle source
Dependencies

Returns a list of Backup's dependencies

# File lib/backup/cli/utility.rb, line 189
desc 'dependencies', 'Display the list of dependencies for Backup, check the installation status, or install them through Backup.'
generate:config click to toggle source
Generate:Config

Generates the main configuration file

# File lib/backup/cli/utility.rb, line 144
desc 'generate:config', 'Generates the main Backup bootstrap/configuration file'
generate:model click to toggle source
Generate:Model

Generates a model configuration file based on the arguments passed in. For example:

$ backup generate:model --trigger my_backup --databases='mongodb'

will generate a pre-populated model with a base MongoDB setup

# File lib/backup/cli/utility.rb, line 91
desc 'generate:model', "Generates a Backup model file\n\n" +
perform() click to toggle source
# File lib/backup/cli/utility.rb, line 30
def perform
  ##
  # Silence Backup::Logger from printing to STDOUT, if --quiet was specified
  Logger.quiet = options[:quiet]

  ##
  # Update Config variables based on the given options
  Config.update(options)

  ##
  # Ensure the :log_path, :cache_path and :tmp_path are created
  # if they do not yet exist
  [Config.log_path, Config.cache_path, Config.tmp_path].each do |path|
    FileUtils.mkdir_p(path)
  end

  ##
  # Load the configuration file
  Config.load_config!

  ##
  # Truncate log file if needed
  Logger.truncate!

  ##
  # Prepare all trigger names by splitting them by ','
  # and finding trigger names matching wildcard
  triggers = options[:trigger].split(",")
  triggers.map!(&:strip).map! {|t|
    t.include?('*') ? Model.find_matching(t).map(&:trigger) : t
  }.flatten!

  ##
  # Process each trigger
  triggers.each do |trigger|
    ##
    # Find the model for this trigger
    # Will raise an error if not found
    model = Model.find(trigger)

    ##
    # Prepare and Perform the backup
    model.prepare!
    model.perform!

    ##
    # Clear the Log Messages for the next potential run
    Logger.clear!
  end

rescue => err
  Logger.error Errors::CLIError.wrap(err)
  exit(1)
end
trigger click to toggle source
Perform

Performs the backup process. The only required option is the --trigger [-t]. If the other options (--config-file, --data-path, --cache--path, --tmp-path) aren't specified they will fallback to the (good) defaults

If --root-path is given, it will be used as the base path for our defaults, as well as the base path for any option specified as a relative path. Any option given as an absolute path will be used "as-is".

# File lib/backup/cli/utility.rb, line 18
method_option :trigger,         :type => :string,  :required => true, :aliases => ['-t', '--triggers']
version() click to toggle source
# File lib/backup/cli/utility.rb, line 237
def version
  puts "Backup #{Backup::Version.current}"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.