Browse Source

Spawn borg and pass input

master
Jim Paris 11 months ago
parent
commit
4a707968ab
1 changed files with 24 additions and 16 deletions
  1. +24
    -16
      backup.py

+ 24
- 16
backup.py View File

@@ -235,22 +235,30 @@ def main(argv: list[str]):
with open(os.devnull, "wb") as out:
backup.run(out)
else:
# subprocess.Popen([args.borg,
# "create",
# "--verbose",
# "--list",
# "--filter", "E",
# "--stats",
# "--exclude-caches"])
# --stats \
# --exclude-caches \
# --one-file-system \
# --checkpoint-interval 900 \
# --compression zstd,3 \
# ::'{hostname}-{now:%Y%m%d-%H%M%S}' \
# $BORG_BACKUP_DIRS
backup.run(sys.stdout.buffer)
borg = subprocess.Popen([args.borg,
"create",
"--verbose",
"--list",
"--filter", "E",
"--stats",
"--checkpoint-interval", "900",
"--compression", "zstd,3",
"--paths-from-stdin",
"--paths-delimiter", "\\0",
"::'{hostname}-{now:%Y%m%d-%H%M%S}'"],
stdin=subprocess.PIPE)
backup.run(borg.stdin)
borg.stdin.close()
ret = borg.wait()
if ret < 0:
sys.stderr.write(f"error: process exited with signal {-ret}\n")
return 1
elif ret != 0:
sys.stderr.write(f"error: process exited with return code {ret}\n")
return ret

return 0

if __name__ == "__main__":
import sys
main(sys.argv)
raise SystemExit(main(sys.argv))

Loading…
Cancel
Save