mirror of
https://codeberg.org/puppe/mpbackup.git
synced 2025-12-20 05:52:18 +01:00
Improve text output for users
This commit is contained in:
parent
6388495fc7
commit
ee2e4d7129
1 changed files with 7 additions and 4 deletions
11
mpbackup
11
mpbackup
|
|
@ -34,10 +34,11 @@ if !Pathname.new(config_file).exist? then
|
||||||
end
|
end
|
||||||
|
|
||||||
def do_backup(config)
|
def do_backup(config)
|
||||||
|
puts "Applying configuration ‘#{config['name']}’ …"
|
||||||
ENV['RESTIC_REPOSITORY'] = config['repository']
|
ENV['RESTIC_REPOSITORY'] = config['repository']
|
||||||
ENV['RESTIC_PASSWORD'] = STDIN.getpass('Please put in your restic password: ')
|
ENV['RESTIC_PASSWORD'] = STDIN.getpass('Please put in your restic password: ')
|
||||||
|
|
||||||
puts "Backing up with restic…"
|
puts "Backing up with restic …"
|
||||||
# https://restic.readthedocs.io/en/latest/040_backup.html#including-and-excluding-files
|
# https://restic.readthedocs.io/en/latest/040_backup.html#including-and-excluding-files
|
||||||
exclude = config.dig('backup', 'exclude')&.flat_map{|e| ['--exclude', e]} || []
|
exclude = config.dig('backup', 'exclude')&.flat_map{|e| ['--exclude', e]} || []
|
||||||
paths = config.dig('backup', 'paths') || []
|
paths = config.dig('backup', 'paths') || []
|
||||||
|
|
@ -49,7 +50,7 @@ def do_backup(config)
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
puts 'Checking restic repo…'
|
puts 'Checking restic repo …'
|
||||||
check_command = ['restic', 'check']
|
check_command = ['restic', 'check']
|
||||||
puts("Command: #{check_command.join(' ')}")
|
puts("Command: #{check_command.join(' ')}")
|
||||||
system(*check_command)
|
system(*check_command)
|
||||||
|
|
@ -58,7 +59,7 @@ def do_backup(config)
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Deleting unnecessary snapshots…"
|
puts "Deleting unnecessary snapshots …"
|
||||||
flags = config['forget'].filter{|k,v| k != 'enable'}
|
flags = config['forget'].filter{|k,v| k != 'enable'}
|
||||||
flags = flags.flat_map{|k,v| ['--' + k, v.to_s]}
|
flags = flags.flat_map{|k,v| ['--' + k, v.to_s]}
|
||||||
forget_command = ['restic', 'forget'] + flags
|
forget_command = ['restic', 'forget'] + flags
|
||||||
|
|
@ -75,9 +76,11 @@ def do_backup(config)
|
||||||
ENV.delete('RESTIC_PASSWORD')
|
ENV.delete('RESTIC_PASSWORD')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
puts "Using config file #{config_file} …"
|
||||||
configs = YAML.load_stream(File.open(config_file))
|
configs = YAML.load_stream(File.open(config_file))
|
||||||
if ARGV.empty?
|
if ARGV.empty?
|
||||||
puts "No configuration name has been given. Using the first configuration."
|
puts "No configuration name has been given. Will use the first "\
|
||||||
|
"configuration from the file (‘#{configs.dig(0, 'name')}’)."
|
||||||
do_backup(configs[0])
|
do_backup(configs[0])
|
||||||
else
|
else
|
||||||
ARGV.each do |config_name|
|
ARGV.each do |config_name|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue