summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-02-08 20:23:14 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-02-08 20:23:14 +0100
commit96e8727ce0ad878ee590dd942228356c4c12d593 (patch)
treeea6eee9a27c4202540fb0bf992264cf9a84867c6
parenteccf2f4dc837993818658271e47ba3cdaea3894f (diff)
downloadnixos-96e8727ce0ad878ee590dd942228356c4c12d593.tar
nixos-96e8727ce0ad878ee590dd942228356c4c12d593.tar.gz
nixos-96e8727ce0ad878ee590dd942228356c4c12d593.tar.bz2
nixos-96e8727ce0ad878ee590dd942228356c4c12d593.tar.xz
nixos-96e8727ce0ad878ee590dd942228356c4c12d593.zip
ymir: ...
-rwxr-xr-xsnap.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/snap.py b/snap.py
index 80487292..49c1adaa 100755
--- a/snap.py
+++ b/snap.py
@@ -24,14 +24,14 @@ def waitchildren():
24 children.remove(waitpid) 24 children.remove(waitpid)
25 25
26 26
27def borg_lv(lv, size_percent, target, archive_prefix, dry_run, **args): 27def borg_lv(lv, target, archive_prefix, dry_run, **args):
28 vgp = lv.split('/') 28 vgp = lv.split('/')
29 lvn = vgp[-1] 29 lvn = vgp[-1]
30 snn = f'{lvn}_snap_{datetime.utcnow().strftime("%Y%m%dT%H%MZ")}' 30 snn = f'{lvn}_snap_{datetime.utcnow().strftime("%Y%m%dT%H%MZ")}'
31 sn = "/".join([*vgp[:-1], snn]) 31 sn = "/".join([*vgp[:-1], snn])
32 32
33 try: 33 try:
34 subprocess.run(['lvcreate', f'-l{size_percent}%ORIGIN', '-s', '-n', snn, lv], stdin=subprocess.DEVNULL, check=True) 34 subprocess.run(['lvcreate', f'-l100%FREE', '-s', '-n', snn, lv], stdin=subprocess.DEVNULL, check=True)
35 35
36 creation_time = None 36 creation_time = None
37 with subprocess.Popen(['lvs', '--reportformat=json', '-olv_time', sn], stdout=subprocess.PIPE) as proc: 37 with subprocess.Popen(['lvs', '--reportformat=json', '-olv_time', sn], stdout=subprocess.PIPE) as proc:
@@ -105,7 +105,6 @@ def main():
105 105
106 parser = argparse.ArgumentParser() 106 parser = argparse.ArgumentParser()
107 parser.add_argument('lv', metavar='LV') 107 parser.add_argument('lv', metavar='LV')
108 parser.add_argument('--size-percent', metavar='PERCENT', type = float, default=10)
109 parser.add_argument('--target', metavar='REPO', default='borg.vidhar:.') 108 parser.add_argument('--target', metavar='REPO', default='borg.vidhar:.')
110 parser.add_argument('--archive-prefix', metavar='REPO', default='yggdrasil.niflheim.ymir.') 109 parser.add_argument('--archive-prefix', metavar='REPO', default='yggdrasil.niflheim.ymir.')
111 parser.add_argument('--dry-run', action='store_true') 110 parser.add_argument('--dry-run', action='store_true')