From 5110e64e6324b7fcde19c90d01893ac1ab17bf24 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 4 Jul 2017 18:23:59 -0700 Subject: [PATCH] Integrating YAML config into borgmatic and updating README. --- README.md | 38 +++++++++++++++++++++----------------- borgmatic/command.py | 8 ++++---- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7eb0eb1b5..5e69283ae 100644 --- a/README.md +++ b/README.md @@ -13,24 +13,28 @@ all on the command-line, and handles common errors. 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* +```yaml +location: + # 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 + # 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 +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 +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 @@ -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".) 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 file](https://torsion.org/hg/borgmatic/raw-file/tip/sample/excludes). From the directory where you downloaded them: 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. diff --git a/borgmatic/command.py b/borgmatic/command.py index ef7bbee6f..cba6ef3af 100644 --- a/borgmatic/command.py +++ b/borgmatic/command.py @@ -5,10 +5,10 @@ from subprocess import CalledProcessError import sys 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' @@ -43,7 +43,7 @@ def parse_arguments(*arguments): def main(): try: 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'] 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.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) sys.exit(1)