From bf817d8829b4357888e16f29eb1251fc0599635a Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Tue, 29 Mar 2022 21:29:25 +0200 Subject: [PATCH] Added routine to delete symlink if exists --- docker-volume-backup.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker-volume-backup.py b/docker-volume-backup.py index 2b0401a..fb08733 100644 --- a/docker-volume-backup.py +++ b/docker-volume-backup.py @@ -52,6 +52,10 @@ version_dir = versions_dir + backup_time + "/" latest_link = backup_type_dir + "/latest/" # Create folder to store version in pathlib.Path(version_dir).mkdir(parents=True, exist_ok=True) + +if pathlib.Path(latest_link).is_symlink(): + print("Unlink " + latest_link + "...") + pathlib.Path(latest_link).unlink() # Link latest to current version pathlib.Path(latest_link).symlink_to(version_dir)