Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backup and restore crontab file #263

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
use f string instead of format
AlexanderProd committed Apr 7, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a46498cfa70b40dc25427e8d8ab9c9e64a487807
5 changes: 2 additions & 3 deletions shallow_backup/reinstall.py
Original file line number Diff line number Diff line change
@@ -74,11 +74,10 @@ def reinstall_configs_sb(configs_path):
copyfile(path_to_backup, dest_path)

# reinstall crontab
with open(os.path.join(configs_path, "/crontab.txt"), "r") as f:
with open(os.path.join(configs_path, "crontab.txt"), "r") as f:
for x in f:
# the replace sanitizes the crontab line of any present " characters.
cmd = "(crontab -l ; echo \"{0}\") | sort - | uniq - | crontab -".format(
x.replace('"', '\\"'))
cmd = f"(crontab -l ; echo \"{x.replace('"', '\\"'))}\") | sort - | uniq - | crontab -"
run_cmd(cmd)

print_section_header("CONFIG REINSTALLATION COMPLETED", Fore.BLUE)