Sha256: 97ed9ed68c468fbb0c94b3b5eac2e2a9bb19ad0ea9bda9253b9365a025aebf21

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require "bup"
require "optparse"

configfile = File.join(ENV["HOME"], ".buprc")
config = Bup::Config.new
profile = nil

OptParse.new do |opt|
  opt.banner = "#{$PROGRAM_NAME} #{Bup::VERSION}"

  opt.on("-c", "--config=file", String, "Config file.") do |c|
    configfile = c
  end

  opt.on("-p", "--profile=profile", String, "Profile name.") do |p|
    profile = p
  end

  opt.on("-i", "--incremental", String, "Set the type of backup to incremental.") do 
    config.runtime["type"] = "incremental"
  end

  opt.on("-f", "--full", String, "Set the type of backup to full.") do 
    config.runtime["type"] = "full"
  end

  opt.on("-l", "--list", "List profiles and exit.") do
    config.runtime["action"] = "list"
  end
end.parse!

config.load(configfile) if File.exist?(configfile)

if profile
  config.runtime["profile"] = profile
elsif config.config["default_profile"]
  config.runtime["profile"] = config.config["default_profile"]
end


case config.runtime["action"]
when "list"
  config.config["profiles"].each do |key, profile|
    puts "#{key} - #{profile["description"] || ""}"
  end
else
  tar = Bup::Tar.new(config)
  tar.call
  config.save(configfile)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bup-0.7.0 exe/bup
bup-0.6.0 exe/bup