diff options
| -rwxr-xr-x | hosts/vidhar/borg/copy.py | 4 | ||||
| -rw-r--r-- | hosts/vidhar/borg/default.nix | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index 38502a28..0d0104ff 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py | |||
| @@ -81,7 +81,7 @@ def copy_archive(src_repo_path, dst_repo_path, entry): | |||
| 81 | sp.succeed(f'Will process {entry["name"]} ({dateutil.parser.isoparse(entry["start"])}, cache_suffix={cache_suffix})') | 81 | sp.succeed(f'Will process {entry["name"]} ({dateutil.parser.isoparse(entry["start"])}, cache_suffix={cache_suffix})') |
| 82 | else: | 82 | else: |
| 83 | print(f'Will process {entry["name"]} ({dateutil.parser.isoparse(entry["start"])}, cache_suffix={cache_suffix})', file=stderr) | 83 | print(f'Will process {entry["name"]} ({dateutil.parser.isoparse(entry["start"])}, cache_suffix={cache_suffix})', file=stderr) |
| 84 | with TemporaryDirectory(prefix=f'borg-mount_{entry["name"]}_') as tmpdir: | 84 | with TemporaryDirectory(prefix=f'borg-mount_{entry["name"]}_', dir=os.environ.get('RUNTIME_DIRECTORY')) as tmpdir: |
| 85 | child = os.fork() | 85 | child = os.fork() |
| 86 | if child == 0: | 86 | if child == 0: |
| 87 | # print('unshare/chroot', file=stderr) | 87 | # print('unshare/chroot', file=stderr) |
| @@ -100,6 +100,8 @@ def copy_archive(src_repo_path, dst_repo_path, entry): | |||
| 100 | work = pathlib.Path(tmpdir) / 'work' | 100 | work = pathlib.Path(tmpdir) / 'work' |
| 101 | for path in [chroot,upper,work]: | 101 | for path in [chroot,upper,work]: |
| 102 | path.mkdir() | 102 | path.mkdir() |
| 103 | print(f'euid={os.getuid()}', file=stderr) | ||
| 104 | subprocess.run(['stat', '/', upper, work, chroot], check=True) | ||
| 103 | subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/,upperdir={upper},workdir={work}', chroot], check=True) | 105 | subprocess.run(['mount', '-t', 'overlay', 'overlay', '-o', f'lowerdir=/,upperdir={upper},workdir={work}', chroot], check=True) |
| 104 | bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] | 106 | bindMounts = ['nix', 'run', 'proc', 'dev', 'sys', pathlib.Path(os.path.expanduser('~')).relative_to('/')] |
| 105 | if not ":" in src_repo_path: | 107 | if not ":" in src_repo_path: |
diff --git a/hosts/vidhar/borg/default.nix b/hosts/vidhar/borg/default.nix index cdb94e26..170ef65d 100644 --- a/hosts/vidhar/borg/default.nix +++ b/hosts/vidhar/borg/default.nix | |||
| @@ -25,6 +25,7 @@ let | |||
| 25 | User = "borg"; | 25 | User = "borg"; |
| 26 | Group = "borg"; | 26 | Group = "borg"; |
| 27 | StateDirectory = "borg"; | 27 | StateDirectory = "borg"; |
| 28 | RuntimeDirectory = "copy-borg"; | ||
| 28 | Environment = [ | 29 | Environment = [ |
| 29 | "BORG_RSH=\"${pkgs.openssh}/bin/ssh -F ${sshConfig}\"" | 30 | "BORG_RSH=\"${pkgs.openssh}/bin/ssh -F ${sshConfig}\"" |
| 30 | "BORG_BASE_DIR=/var/lib/borg" | 31 | "BORG_BASE_DIR=/var/lib/borg" |
