summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-08 16:20:33 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-08 16:20:33 +0100
commitf3199d96485114cf6399bccd4b6c590735bc59e8 (patch)
treec92d194399ddcf02daceb2bfc7594da46ae6e391
parentcf797eca5f8d6a9c12530b4519cb100a46eef51c (diff)
downloadnixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar
nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar.gz
nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar.bz2
nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.tar.xz
nixos-f3199d96485114cf6399bccd4b6c590735bc59e8.zip
ymir: ...
-rwxr-xr-xsnap.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/snap.py b/snap.py
index 1151c718..68a62c7c 100755
--- a/snap.py
+++ b/snap.py
@@ -15,7 +15,7 @@ import pathlib
15import unshare 15import unshare
16 16
17 17
18def borg_lv(lv, size_percent, target, archive_prefix, **args): 18def 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))