diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-18 13:03:58 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-18 13:03:58 +0100 |
commit | 53bb5d4d17e2a1563900c63b31213395543e0e55 (patch) | |
tree | a190d384d420274693e5ab68eaa5478c25e9e91c /hosts | |
parent | cc1097378d095adf05a37261ac663a7019b3292c (diff) | |
download | nixos-53bb5d4d17e2a1563900c63b31213395543e0e55.tar nixos-53bb5d4d17e2a1563900c63b31213395543e0e55.tar.gz nixos-53bb5d4d17e2a1563900c63b31213395543e0e55.tar.bz2 nixos-53bb5d4d17e2a1563900c63b31213395543e0e55.tar.xz nixos-53bb5d4d17e2a1563900c63b31213395543e0e55.zip |
vidhar: ...
Diffstat (limited to 'hosts')
-rwxr-xr-x | hosts/vidhar/borg/copy.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index 38e719cf..d8d19a86 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py | |||
@@ -131,6 +131,12 @@ def copy_archive(src_repo_path, dst_repo_path, entry): | |||
131 | (chroot / bindMount).mkdir(parents=True,exist_ok=True) | 131 | (chroot / bindMount).mkdir(parents=True,exist_ok=True) |
132 | # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr) | 132 | # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr) |
133 | subprocess.run(['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], check=True) | 133 | subprocess.run(['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], check=True) |
134 | try: | ||
135 | os.unlink('/etc/fuse.conf') | ||
136 | except FileNotFoundError: | ||
137 | pass | ||
138 | with open('/etc/fuse.conf', 'w') as fuse_conf: | ||
139 | fuse_conf.write('user_allow_other\nmount_max = 1000\n') | ||
134 | os.chroot(chroot) | 140 | os.chroot(chroot) |
135 | os.chdir('/') | 141 | os.chdir('/') |
136 | dir = pathlib.Path('/borg') | 142 | dir = pathlib.Path('/borg') |
@@ -150,12 +156,11 @@ def copy_archive(src_repo_path, dst_repo_path, entry): | |||
150 | else: | 156 | else: |
151 | print(f'{total_files} files, {naturalsize(total_size, binary=True)}', file=stderr) | 157 | print(f'{total_files} files, {naturalsize(total_size, binary=True)}', file=stderr) |
152 | # print(f'Mounting to {dir}', file=stderr) | 158 | # print(f'Mounting to {dir}', file=stderr) |
153 | with subprocess.Popen(['borg', 'mount', '--foreground', '--progress', '--lock-wait=600', f'{src_repo_path}::{entry["name"]}', dir], preexec_fn=lambda: as_borg()) as mount_proc: | 159 | with subprocess.Popen(['borg', 'mount', '-o', 'allow_other', '--foreground', '--progress', '--lock-wait=600', f'{src_repo_path}::{entry["name"]}', dir], preexec_fn=lambda: as_borg()) as mount_proc: |
154 | with Halo(text='Waiting for mount', **halo_args) as sp: | 160 | with Halo(text='Waiting for mount', **halo_args) as sp: |
155 | wait_start = datetime.now() | 161 | wait_start = datetime.now() |
156 | while True: | 162 | while True: |
157 | ret = subprocess.run(['mountpoint', '-q', dir], preexec_fn=lambda: as_borg()) | 163 | if os.path.ismount(dir): |
158 | if ret.returncode == 0: | ||
159 | break | 164 | break |
160 | elif datetime.now() - wait_start > timedelta(minutes=15): | 165 | elif datetime.now() - wait_start > timedelta(minutes=15): |
161 | ret.check_returncode() | 166 | ret.check_returncode() |