Added routine to delete symlink if exists

This commit is contained in:
Kevin Veen-Birkenbach 2022-03-29 21:29:25 +02:00
parent 03a8b56093
commit bf817d8829

View File

@ -52,6 +52,10 @@ version_dir = versions_dir + backup_time + "/"
latest_link = backup_type_dir + "/latest/" latest_link = backup_type_dir + "/latest/"
# Create folder to store version in # Create folder to store version in
pathlib.Path(version_dir).mkdir(parents=True, exist_ok=True) 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 # Link latest to current version
pathlib.Path(latest_link).symlink_to(version_dir) pathlib.Path(latest_link).symlink_to(version_dir)