Bladeren bron

Integrating YAML config into borgmatic and updating README.

Dan Helfman 8 jaren geleden
bovenliggende
commit
5110e64e63
2 gewijzigde bestanden met toevoegingen van 28 en 24 verwijderingen
  1. 24 20
      README.md
  2. 4 4
      borgmatic/command.py

+ 24 - 20
README.md

@@ -13,24 +13,28 @@ all on the command-line, and handles common errors.
 
 
 Here's an example config file:
 Here's an example config file:
 
 
-```INI
-[location]
-# Space-separated list of source directories to backup.
-# Globs are expanded.
-source_directories: /home /etc /var/log/syslog*
-
-# Path to local or remote backup repository.
-repository: user@backupserver:sourcehostname.borg
-
-[retention]
-# Retention policy for how many backups to keep in each category.
-keep_daily: 7
-keep_weekly: 4
-keep_monthly: 6
-
-[consistency]
-# Consistency checks to run, or "disabled" to prevent checks.
-checks: repository archives
+```yaml
+location:
+    # List of source directories to backup. Globs are expanded.
+    source_directories:
+        - /home
+        - /etc
+        - /var/log/syslog*
+
+    # Path to local or remote repository.
+    repository: user@backupserver:sourcehostname.borg
+
+retention:
+    # Retention policy for how many backups to keep in each category.
+    keep_daily: 7
+    keep_weekly: 4
+    keep_monthly: 6
+
+consistency:
+    # List of consistency checks to run: "repository", "archives", or both.
+    checks:
+        - repository
+        - archives
 ```
 ```
 
 
 Additionally, exclude patterns can be specified in a separate excludes config
 Additionally, exclude patterns can be specified in a separate excludes config
@@ -63,13 +67,13 @@ Make sure you're using Python 3, as borgmatic does not support Python 2. (You
 may have to use "pip3" instead of "pip".)
 may have to use "pip3" instead of "pip".)
 
 
 Then, download a [sample config
 Then, download a [sample config
-file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/config) and a
+file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/config.yaml) and a
 [sample excludes
 [sample excludes
 file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/excludes). From the
 file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/excludes). From the
 directory where you downloaded them:
 directory where you downloaded them:
 
 
     sudo mkdir /etc/borgmatic/
     sudo mkdir /etc/borgmatic/
-    sudo mv config excludes /etc/borgmatic/
+    sudo mv config.yaml excludes /etc/borgmatic/
 
 
 Lastly, modify the /etc files with your desired configuration.
 Lastly, modify the /etc files with your desired configuration.
 
 

+ 4 - 4
borgmatic/command.py

@@ -5,10 +5,10 @@ from subprocess import CalledProcessError
 import sys
 import sys
 
 
 from borgmatic import borg
 from borgmatic import borg
-from borgmatic.config.legacy import parse_configuration, CONFIG_FORMAT
+from borgmatic.config.yaml import parse_configuration, schema_filename
 
 
 
 
-DEFAULT_CONFIG_FILENAME = '/etc/borgmatic/config'
+DEFAULT_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'
 DEFAULT_EXCLUDES_FILENAME = '/etc/borgmatic/excludes'
 DEFAULT_EXCLUDES_FILENAME = '/etc/borgmatic/excludes'
 
 
 
 
@@ -43,7 +43,7 @@ def parse_arguments(*arguments):
 def main():
 def main():
     try:
     try:
         args = parse_arguments(*sys.argv[1:])
         args = parse_arguments(*sys.argv[1:])
-        config = parse_configuration(args.config_filename, CONFIG_FORMAT)
+        config = parse_configuration(args.config_filename, schema_filename())
         repository = config.location['repository']
         repository = config.location['repository']
         remote_path = config.location.get('remote_path')
         remote_path = config.location.get('remote_path')
 
 
@@ -53,6 +53,6 @@ def main():
         )
         )
         borg.prune_archives(args.verbosity, repository, config.retention, remote_path=remote_path)
         borg.prune_archives(args.verbosity, repository, config.retention, remote_path=remote_path)
         borg.check_archives(args.verbosity, repository, config.consistency, remote_path=remote_path)
         borg.check_archives(args.verbosity, repository, config.consistency, remote_path=remote_path)
-    except (ValueError, IOError, CalledProcessError) as error:
+    except (ValueError, OSError, CalledProcessError) as error:
         print(error, file=sys.stderr)
         print(error, file=sys.stderr)
         sys.exit(1)
         sys.exit(1)