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():
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"]
restic_cmd_base = "restic " \
f"--repo s3:https://{args.bucket_endpoint}/the-nine-worlds---{service} " \
@ -45,9 +47,7 @@ if __name__ == "__main__":
try:
subprocess.run(f"{restic_cmd_base} snapshots || {restic_cmd_base} init",
shell=True, check=True)
subprocess.run(f"cd {backup_path} && "
f"{restic_cmd_base} backup .",
shell=True, check=True)
subprocess.run(f"{restic_cmd_base} backup .", shell=True, cwd=backup_path, check=True)
subprocess.run(f"{restic_cmd_base} forget --prune --keep-daily 90 --keep-monthly 12",
shell=True, check=True)
subprocess.run(f"{restic_cmd_base} check", shell=True, check=True)