mirror of
https://codeberg.org/Mo8it/dotfiles.git
synced 2024-10-17 20:52:40 +00:00
Ask to init restic repo if not found
This commit is contained in:
parent
9f80615cb8
commit
c6d687367d
1 changed files with 12 additions and 2 deletions
|
@ -71,8 +71,15 @@ def pre_backup():
|
|||
write_home_visible_includes()
|
||||
|
||||
repo = mounted_backup_drive() / "restic"
|
||||
init_repo = False
|
||||
if not repo.is_dir():
|
||||
raise Exception(f"No repo found at {repo} !!")
|
||||
decorated_print(f"No repo found at {repo} !!")
|
||||
|
||||
ans = input("Initialize repo? [Y/n]: ")
|
||||
if ans.strip().lower() not in ("", "y"):
|
||||
raise Exception("No repo to work with!")
|
||||
else:
|
||||
init_repo = True
|
||||
|
||||
with open(CONFIG_PATH / "pre_backup_scripts.txt") as f:
|
||||
for line in f:
|
||||
|
@ -86,6 +93,9 @@ def pre_backup():
|
|||
env["RESTIC_REPOSITORY"] = repo
|
||||
env["RESTIC_PASSWORD"] = password
|
||||
|
||||
if init_repo:
|
||||
run("restic init", env=env, check=True)
|
||||
|
||||
return env
|
||||
|
||||
|
||||
|
@ -95,7 +105,7 @@ def backup(env):
|
|||
excludes = CONFIG_PATH / "excludes.txt"
|
||||
|
||||
run(
|
||||
f"restic backup -vv --files-from {home_visible_includes} --files-from {includes} --exclude-file {excludes}",
|
||||
f"restic backup -v --files-from {home_visible_includes} --files-from {includes} --exclude-file {excludes}",
|
||||
env=env,
|
||||
check=True,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue