Integrating YAML config into borgmatic and updating README.

This commit is contained in:
Dan Helfman 2017-07-04 18:23:59 -07:00
parent 4d7556f68b
commit 5110e64e63
2 changed files with 25 additions and 21 deletions

View File

@ -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 ```yaml
[location] location:
# Space-separated list of source directories to backup. # List of source directories to backup. Globs are expanded.
# Globs are expanded. source_directories:
source_directories: /home /etc /var/log/syslog* - /home
- /etc
- /var/log/syslog*
# Path to local or remote backup repository. # Path to local or remote repository.
repository: user@backupserver:sourcehostname.borg repository: user@backupserver:sourcehostname.borg
[retention] retention:
# Retention policy for how many backups to keep in each category. # Retention policy for how many backups to keep in each category.
keep_daily: 7 keep_daily: 7
keep_weekly: 4 keep_weekly: 4
keep_monthly: 6 keep_monthly: 6
[consistency] consistency:
# Consistency checks to run, or "disabled" to prevent checks. # List of consistency checks to run: "repository", "archives", or both.
checks: repository archives 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.

View File

@ -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)