summaryrefslogtreecommitdiff
path: root/hosts/vidhar/borg
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vidhar/borg')
-rwxr-xr-xhosts/vidhar/borg/copy.py7
-rw-r--r--hosts/vidhar/borg/default.nix2
2 files changed, 5 insertions, 4 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py
index e6cf2ac4..1714e2e8 100755
--- a/hosts/vidhar/borg/copy.py
+++ b/hosts/vidhar/borg/copy.py
@@ -118,8 +118,6 @@ def copy_archive(src_repo_path, dst_repo_path, entry):
118 bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] 118 bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')]
119 if os.environ.get('BORG_BASE_DIR'): 119 if os.environ.get('BORG_BASE_DIR'):
120 bindMounts.append(pathlib.Path(os.environ['BORG_BASE_DIR']).relative_to('/')) 120 bindMounts.append(pathlib.Path(os.environ['BORG_BASE_DIR']).relative_to('/'))
121 if os.environ.get('CREDENTIALS_DIRECTORY'):
122 bindMounts.append(pathlib.Path(os.environ['CREDENTIALS_DIRECTORY']).relative_to('/'))
123 if not ":" in src_repo_path: 121 if not ":" in src_repo_path:
124 bindMounts.append(pathlib.Path(src_repo_path).relative_to('/')) 122 bindMounts.append(pathlib.Path(src_repo_path).relative_to('/'))
125 if 'SSH_AUTH_SOCK' in os.environ: 123 if 'SSH_AUTH_SOCK' in os.environ:
@@ -128,6 +126,9 @@ def copy_archive(src_repo_path, dst_repo_path, entry):
128 (chroot / bindMount).mkdir(parents=True,exist_ok=True) 126 (chroot / bindMount).mkdir(parents=True,exist_ok=True)
129 # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr) 127 # print(*['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], file=stderr)
130 subprocess.run(['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], check=True) 128 subprocess.run(['mount', '--bind', pathlib.Path('/') / bindMount, chroot / bindMount], check=True)
129 if os.environ.get('CREDENTIALS_DIRECTORY'):
130 creds_path = pathlib.Path(os.environ['CREDENTIALS_DIRECTORY']).relative_to('/')
131 subprocess.run(['binfs', '-r', f'--force-user={borg_pwd.pw_uid}', f'--force-group={borg_pwd.pw_gid}', pathlib.Path('/') / creds_path, chroot / creds_path], check=True)
131 os.chroot(chroot) 132 os.chroot(chroot)
132 os.chdir('/') 133 os.chdir('/')
133 dir = pathlib.Path('/borg') 134 dir = pathlib.Path('/borg')
@@ -248,7 +249,7 @@ def sigterm(signum, frame):
248 249
249def main(): 250def main():
250 signal.signal(signal.SIGTERM, sigterm) 251 signal.signal(signal.SIGTERM, sigterm)
251 252
252 if "::" in args.source: 253 if "::" in args.source:
253 (src_repo_path, _, src_archive) = args.source.partition("::") 254 (src_repo_path, _, src_archive) = args.source.partition("::")
254 entry = None 255 entry = None
diff --git a/hosts/vidhar/borg/default.nix b/hosts/vidhar/borg/default.nix
index 37cdba8c..53b36d82 100644
--- a/hosts/vidhar/borg/default.nix
+++ b/hosts/vidhar/borg/default.nix
@@ -72,7 +72,7 @@ let
72 copy 72 copy
73 73
74 wrapProgram $out/bin/copy \ 74 wrapProgram $out/bin/copy \
75 --prefix PATH : ${makeBinPath (with pkgs; [utillinux borgbackup])} 75 --prefix PATH : ${makeBinPath (with pkgs; [utillinux borgbackup bindfs])}
76 ''; 76 '';
77 }); 77 });
78in { 78in {