diff --git a/mpbackup b/mpbackup index 0f99ac2..a7060e7 100644 --- a/mpbackup +++ b/mpbackup @@ -34,10 +34,11 @@ if !Pathname.new(config_file).exist? then end def do_backup(config) + puts "Applying configuration ‘#{config['name']}’ …" ENV['RESTIC_REPOSITORY'] = config['repository'] 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 exclude = config.dig('backup', 'exclude')&.flat_map{|e| ['--exclude', e]} || [] paths = config.dig('backup', 'paths') || [] @@ -49,7 +50,7 @@ def do_backup(config) exit 1 end - puts 'Checking restic repo…' + puts 'Checking restic repo …' check_command = ['restic', 'check'] puts("Command: #{check_command.join(' ')}") system(*check_command) @@ -58,7 +59,7 @@ def do_backup(config) exit 1 end - puts "Deleting unnecessary snapshots…" + puts "Deleting unnecessary snapshots …" flags = config['forget'].filter{|k,v| k != 'enable'} flags = flags.flat_map{|k,v| ['--' + k, v.to_s]} forget_command = ['restic', 'forget'] + flags @@ -75,9 +76,11 @@ def do_backup(config) ENV.delete('RESTIC_PASSWORD') end +puts "Using config file #{config_file} …" configs = YAML.load_stream(File.open(config_file)) 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]) else ARGV.each do |config_name|