Add support for specifying tags for backups

This commit is contained in:
Martin Puppe 2021-03-04 09:31:29 +01:00
parent 67058870e2
commit 0d98802d8a

View file

@ -62,9 +62,11 @@ end
def backup(config) def backup(config)
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
flags = config['backup'].select{|k,v| k != 'exclude' && k != 'paths'} flags = config['backup'].select{|k,v|
k != 'exclude' && k != 'paths' && k != 'tags'}
flags = flags.map{|k,v| "--#{k}=#{v.to_s}"} flags = flags.map{|k,v| "--#{k}=#{v.to_s}"}
exclude = config.dig('backup', 'exclude')&.flat_map{|e| ['--exclude', e]} || [] exclude = config.dig('backup', 'exclude')&.flat_map{|e| ['--exclude', e]} || []
tags = config.dig('backup', 'tags')&.flat_map{|t| ['--tag', t]} || []
paths = config.dig('backup', 'paths') || [] paths = config.dig('backup', 'paths') || []
backup_command = ['restic', 'backup', *exclude, *paths, *flags] backup_command = ['restic', 'backup', *exclude, *paths, *flags]
puts("Command: #{backup_command.join(' ')}") puts("Command: #{backup_command.join(' ')}")