Browse Source

added backup config option 'name'

Fabian Peter Hammerle 7 years ago
parent
commit
f85c9561bd
2 changed files with 11 additions and 2 deletions
  1. 2 1
      README.md
  2. 9 1
      scripts/duplitab

+ 2 - 1
README.md

@@ -5,7 +5,8 @@ wrapper for duplicity featuring persistent backup configuration
 
 ```yaml
 # /etc/duplitab
--   source_path: /home
+-   name: home at media backup
+    source_path: /home
     target_url: file:///media/backup/home
     encryption: no
 -   source_path: /secret/folder

+ 9 - 1
scripts/duplitab

@@ -68,6 +68,10 @@ def backup(config, duplicity_verbosity, no_print_config, no_print_statistics, ta
 
         backup_command = ['duplicity']
 
+        # name
+        if backup['name']:
+            backup_command += ['--name', backup['name']]
+
         # encryption
         try:
             encryption = backup['encryption']
@@ -138,7 +142,8 @@ def backup(config, duplicity_verbosity, no_print_config, no_print_statistics, ta
                         )
                     # set backup name to make archive dir persistent
                     # (default name: hash of target url)
-                    backup_command += ['--name', hashlib.sha1(backup['target_url'].encode('utf-8')).hexdigest()]
+                    if not backup['name']:
+                        backup_command += ['--name', hashlib.sha1(backup['target_url'].encode('utf-8')).hexdigest()]
                 else:
                     backup_command += [backup['target_url']]
                 try:
@@ -180,6 +185,8 @@ def run(command, config_path, quiet, duplicity_verbosity,
         config = yaml.load(config_file.read())
 
     for backup_attr in config:
+        if not 'name' in backup_attr:
+            backup_attr['name'] = None
         if not 'source_type' in backup_attr:
             backup_attr['source_type'] = 'local'
         if not 'source_host' in backup_attr:
@@ -195,6 +202,7 @@ def run(command, config_path, quiet, duplicity_verbosity,
 
     if not command or command == 'list':
         columns = collections.OrderedDict([
+            ('name', 'name'),
             ('source type', 'source_type'),
             ('source host', 'source_host'),
             ('source path', 'source_path'),