class Restic::Service::Targets::ResticSFTP

A target that backs up to a SFTP target using Restic

See README.md for the YAML configuration file format

Public Class Methods

new(name) click to toggle source
# File lib/restic/service/targets/restic_sftp.rb, line 10
def initialize(name)
    super
    @username = nil
    @path = nil
end
normalize_yaml(yaml) click to toggle source
# File lib/restic/service/targets/restic_sftp.rb, line 16
def self.normalize_yaml(yaml)
    %w{host username path password}.each do |required_field|
        if !yaml[required_field]
            raise Conf::InvalidConfigurationFile, "missing '#{required_field}' field in target"
        end
    end
    super
end

Public Instance Methods

forget() click to toggle source
# File lib/restic/service/targets/restic_sftp.rb, line 40
def forget
    with_ssh_config do |ssh_config_name|
        run_forget('-r', "sftp:#{ssh_config_name}:#{@path}", 'forget')
    end
end
restic(*args) click to toggle source
# File lib/restic/service/targets/restic_sftp.rb, line 46
def restic(*args)
    with_ssh_config do |ssh_config_name|
        run_restic('-r', "sftp:#{ssh_config_name}:#{@path}", *args)
    end
end
run() click to toggle source
# File lib/restic/service/targets/restic_sftp.rb, line 34
def run
    with_ssh_config do |ssh_config_name|
        run_backup('-r', "sftp:#{ssh_config_name}:#{@path}", 'backup')
    end
end
setup_from_conf(conf, yaml) click to toggle source
# File lib/restic/service/targets/restic_sftp.rb, line 25
def setup_from_conf(conf, yaml)
    super
    @target_name = yaml['name']
    @username  = yaml['username'].to_str
    @path      = yaml['path'].to_str
    @password  = yaml['password'].to_str
    super
end