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:
```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.

View File

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