Fix backup path setup in restic script

This commit is contained in:
Wojciech Kozlowski 2022-10-20 00:17:42 +02:00
parent 227b2c50a3
commit 78176c9aa7

View File

@ -32,7 +32,9 @@ if __name__ == "__main__":
} }
for service, info in snapshots_for_backup.items(): for service, info in snapshots_for_backup.items():
backup_path = os.path.normpath(os.path.join("/", "mnt", os.path.relpath(info["dataset_path"], "/"))) backup_path = os.path.normpath(
os.path.join("/", "mnt", os.path.relpath(info["dataset_path"], "/"))
)
snapshot = info["snapshot"] snapshot = info["snapshot"]
restic_cmd_base = "restic " \ restic_cmd_base = "restic " \
f"--repo s3:https://{args.bucket_endpoint}/the-nine-worlds---{service} " \ f"--repo s3:https://{args.bucket_endpoint}/the-nine-worlds---{service} " \
@ -45,9 +47,7 @@ if __name__ == "__main__":
try: try:
subprocess.run(f"{restic_cmd_base} snapshots || {restic_cmd_base} init", subprocess.run(f"{restic_cmd_base} snapshots || {restic_cmd_base} init",
shell=True, check=True) shell=True, check=True)
subprocess.run(f"cd {backup_path} && " subprocess.run(f"{restic_cmd_base} backup .", shell=True, cwd=backup_path, check=True)
f"{restic_cmd_base} backup .",
shell=True, check=True)
subprocess.run(f"{restic_cmd_base} forget --prune --keep-daily 90 --keep-monthly 12", subprocess.run(f"{restic_cmd_base} forget --prune --keep-daily 90 --keep-monthly 12",
shell=True, check=True) shell=True, check=True)
subprocess.run(f"{restic_cmd_base} check", shell=True, check=True) subprocess.run(f"{restic_cmd_base} check", shell=True, check=True)