class Restic::Service::Targets::RcloneB2
Public Class Methods
normalize_yaml(yaml)
click to toggle source
# File lib/restic/service/targets/rclone_b2.rb, line 7 def self.normalize_yaml(yaml) yaml = B2.normalize_yaml(yaml) if !yaml['src'] raise Conf::InvalidConfigurationFile, "no src field provided for rclone-b2" elsif !File.directory?(yaml['src']) raise Conf::InvalidConfigurationFile, "provided rclone-b2 source #{yaml['src']} does not exist" end yaml end
Public Instance Methods
run()
click to toggle source
# File lib/restic/service/targets/rclone_b2.rb, line 26 def run extra_args = [] if @bandwidth_limit extra_args << '--bwlimit' << @bandwidth_limit.to_s end if @verbose extra_args << "--verbose" end Tempfile.create "rclone-#{@name}", @conf_path.to_path, perm: 0600 do |io| io.puts <<-EOCONF [restic-service] type = b2 account = #{@id} key = #{@key} endpoint = EOCONF io.flush system(@rclone_path.to_path, '--transfers', '16', '--config', io.path, '--delete-during', *@filter.flat_map { |p| ['--filter', p] }, *extra_args, 'sync', @src, "restic-service:#{@bucket}/#{@path}", in: :close) end end
setup_from_conf(conf, yaml)
click to toggle source
Calls superclass method
Restic::Service::Targets::B2#setup_from_conf
# File lib/restic/service/targets/rclone_b2.rb, line 17 def setup_from_conf(conf, yaml) super @rclone_path = conf.tool_path('rclone') @src = yaml['src'] @filter = yaml['filter'] || [] @verbose = yaml.fetch('verbose', true) @conf_path = conf.conf_path end