Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions shallow_backup/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ def backup_configs(backup_path, skip=False):
safe_mkdir(parent_dir)
copyfile(path_to_backup, quote(dest))

# backup crontab
command = "crontab -l"
dest = os.path.join(backup_path, "crontab.txt")
run_cmd_write_stdout(command, dest)


def backup_packages(backup_path, skip=False):
"""
Expand Down
7 changes: 7 additions & 0 deletions shallow_backup/reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def reinstall_configs_sb(configs_path):
elif os.path.isfile(path_to_backup):
copyfile(path_to_backup, dest_path)

# reinstall crontab
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 = f"(crontab -l ; echo \"{x.replace('"', '\\"')}\") | sort - | uniq - | crontab -"
run_cmd(cmd)

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


Expand Down