Class: Restic::Service::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/restic/service/cli.rb

Instance Method Summary collapse

Instance Method Details

#auto(*targets) ⇒ Object



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/restic/service/cli.rb', line 151

def auto(*targets)
    STDOUT.sync = true
    conf = load_conf
    loop do
        puts "#{Time.now} Starting automatic synchronization pass"
        puts ""

        run_sync(conf, *targets)
        run_forget(conf, *targets)

        puts ""
        puts "#{Time.now} Finished automatic synchronization pass"

        sleep conf.period
    end
end

#auto_updateObject



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/restic/service/cli.rb', line 105

def auto_update
    conf = load_conf
    STDOUT.sync = true

    updater = AutoUpdate.new($0)
    if conf.auto_update_restic_service?
        puts "attempting to auto-update restic-service"
        old_version, new_version = updater.update_restic_service
        if old_version != new_version
            puts "updated restic-service from #{old_version} to #{new_version}, restarting"
            exec "bundle", "exec", Gem.ruby, $0, "auto-update"
        else
            puts "restic-service was already up-to-date: #{new_version}"
        end
    else
        puts "updating restic-service disabled in configuration"
    end

    if conf.auto_update_restic?
        auto_update_tool(conf, updater, 'restic', AutoUpdate::RESTIC_RELEASE_VERSION)
    else
        puts "updating restic disabled in configuration"
    end

    if conf.auto_update_rclone?
        auto_update_tool(conf, updater, 'rclone', AutoUpdate::RCLONE_RELEASE_VERSION)
    else
        puts "updating rclone disabled in configuration"
    end
end

#forget(*targets) ⇒ Object



144
145
146
147
148
# File 'lib/restic/service/cli.rb', line 144

def forget(*targets)
    STDOUT.sync = true
    conf = load_conf
    run_forget(conf, *targets)
end

#install_restic(path, platform) ⇒ Object



99
100
101
102
# File 'lib/restic/service/cli.rb', line 99

def install_restic(path, platform)
    updater = AutoUpdate.new($0)
    updater.update_restic(platform, path)
end

#sync(*targets) ⇒ Object



137
138
139
140
141
# File 'lib/restic/service/cli.rb', line 137

def sync(*targets)
    STDOUT.sync = true
    conf = load_conf
    run_sync(conf, *targets)
end

#whereamiObject



89
90
91
92
93
94
95
96
# File 'lib/restic/service/cli.rb', line 89

def whereami
    STDOUT.sync = true
    conf = load_conf
    conf.each_target do |target|
        print "#{target.name}: "
        puts(target.available? ? 'yes' : 'no')
    end
end