Class: Restic::Service::Targets::ResticSFTP

Inherits:
Restic
  • Object
show all
Includes:
SSHTarget
Defined in:
lib/restic/service/targets/restic_sftp.rb

Overview

A target that backs up to a SFTP target using Restic

See README.md for the YAML configuration file format

Constant Summary

Constants inherited from Restic

Restic::Service::Targets::Restic::FORGET_DURATION_KEYS, Restic::Service::Targets::Restic::FORGET_KEYS

Instance Attribute Summary

Attributes inherited from Base

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SSHTarget

#available?, #valid?, #with_ssh_config

Methods inherited from Restic

#one_filesystem?, #parse_forget_setup, #run_backup, #run_forget, #run_restic

Methods inherited from Base

#available?, #nice_commands

Constructor Details

#initialize(name) ⇒ ResticSFTP

Returns a new instance of ResticSFTP.



10
11
12
13
14
# File 'lib/restic/service/targets/restic_sftp.rb', line 10

def initialize(name)
    super
    @username = nil
    @path = nil
end

Class Method Details

.normalize_yaml(yaml) ⇒ Object



16
17
18
19
20
21
22
23
# 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

Instance Method Details

#forgetObject



40
41
42
43
44
# 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

#runObject



34
35
36
37
38
# 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) ⇒ Object



25
26
27
28
29
30
31
32
# 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