My Unix config files and shell scripts, optimized for Fedora, Debian, macOS and Windows (in that order).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

#!/usr/bin/env python3
"""backup-check: Periodically compare checksums of backups in multiple
locations. It's mainly to do a weekly check of all my backup locations and
identify bit rot before it's too late.
Install via `crontab -e`:
0 2 * * 0 /home/noah/bin/backup-check
import codecs
import os.path
import subprocess
# Directories to compare with each other.
ERROR_OUT = "/home/noah/Desktop/Checksum Error.txt"
def main():
# First available disk becomes the common denominator.
master = None
for disk in DIRECTORIES:
if os.path.isdir(disk):
if master is None:
print("Master disk chosen as:", disk)
master = disk
if disk != master:
# Do the comparison.
print("Compare {} <=> {}".format(master, disk))
out = subprocess.check_output(["diff", "-aqr", master, disk])
if len(out):
# Problem!
def error(out):
"""Error, panic!"""
fh =, "w", "utf-8")
if __name__ == "__main__":