diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-08 16:20:33 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-08 16:20:33 +0100 |
commit | f3199d96485114cf6399bccd4b6c590735bc59e8 (patch) | |
tree | c92d194399ddcf02daceb2bfc7594da46ae6e391 | |
parent | cf797eca5f8d6a9c12530b4519cb100a46eef51c (diff) | |
download | nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar.gz nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar.bz2 nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar.xz nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.zip |
ymir: ...
-rwxr-xr-x | snap.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -15,7 +15,7 @@ import pathlib | |||
15 | import unshare | 15 | import unshare |
16 | 16 | ||
17 | 17 | ||
18 | def borg_lv(lv, size_percent, target, archive_prefix, **args): | 18 | def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args): |
19 | vgp = lv.split('/') | 19 | vgp = lv.split('/') |
20 | lvn = vgp[-1] | 20 | lvn = vgp[-1] |
21 | snn = f'{lvn}_snap_{datetime.utcnow().strftime("%Y%m%dT%H%MZ")}' | 21 | snn = f'{lvn}_snap_{datetime.utcnow().strftime("%Y%m%dT%H%MZ")}' |
@@ -75,6 +75,8 @@ def borg_lv(lv, size_percent, target, archive_prefix, **args): | |||
75 | '--keep-exclude-tags' | 75 | '--keep-exclude-tags' |
76 | ] | 76 | ] |
77 | env['BORG_FILES_CACHE_SUFFIX'] = "_".join(vgp) | 77 | env['BORG_FILES_CACHE_SUFFIX'] = "_".join(vgp) |
78 | if dry_run: | ||
79 | create_args += ['--dry-run'] | ||
78 | create_args += [archive] | 80 | create_args += [archive] |
79 | subprocess.run(create_args, cwd=dir, check=True, env=env) | 81 | subprocess.run(create_args, cwd=dir, check=True, env=env) |
80 | 82 | ||
@@ -95,6 +97,7 @@ def main(): | |||
95 | parser.add_argument('--size-percent', metavar='PERCENT', type = float, default=10) | 97 | parser.add_argument('--size-percent', metavar='PERCENT', type = float, default=10) |
96 | parser.add_argument('--target', metavar='REPO', default='borg.vidhar:.') | 98 | parser.add_argument('--target', metavar='REPO', default='borg.vidhar:.') |
97 | parser.add_argument('--archive-prefix', metavar='REPO', default='yggdrasil.niflheim.ymir.') | 99 | parser.add_argument('--archive-prefix', metavar='REPO', default='yggdrasil.niflheim.ymir.') |
100 | parser.add_argument('--dry-run', action='store_true') | ||
98 | args = parser.parse_args() | 101 | args = parser.parse_args() |
99 | 102 | ||
100 | return borg_lv(**vars(args)) | 103 | return borg_lv(**vars(args)) |