Optionally read password from file

This commit is contained in:
Martin Puppe 2020-03-25 18:26:29 +01:00
parent 19f2c23659
commit 95d13588ba

View file

@ -36,7 +36,13 @@ end
def do_backup(config) def do_backup(config)
puts "Applying configuration #{config['name']} …" puts "Applying configuration #{config['name']} …"
ENV['RESTIC_REPOSITORY'] = config['repository'] ENV['RESTIC_REPOSITORY'] = config['repository']
puts "Repository: #{ENV['RESTIC_REPOSITORY']}"
if config['password-file']
puts "Reading password from file #{config['password-file']} …"
ENV['RESTIC_PASSWORD'] = File.open(config['password-file']) {|f| f.readline}
else
ENV['RESTIC_PASSWORD'] = STDIN.getpass('Please put in your restic password: ') ENV['RESTIC_PASSWORD'] = STDIN.getpass('Please put in your restic password: ')
end
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