Checking rsync's integrity

  • Arthur McLean
    Arthur McLean

    I had a couple of problem with rsnapshot over the last few months. One was the PID file. Apparently rsnapshot was killed or something during one of it's runs, and the PID file still existed. So, it never started after that. Two, I had a syntax error in the conf file. Since everything was running via cron, I didn't notice for several weeks. I have written a Python script to run a daily check for these things that I thought I'd share here.

    You'll have to upate for where Python is located, and where your PID file is located. I hope the formatting comes out okay as tabbing is critical in Python.

    import sys, smtplib, os, commands

    server = ""
    fromaddr = ""
    toaddr = ""

    # Check for PID file
    if os.path.isfile("/var/run/rsnapshot/"):
            modTime = "Warning! The file /var/run/rsnapshot/ exists. It's mtime is "
            modTime += str(os.path.getmtime("/var/run/rsnapshot/"))
            modTime += ". You should check to make sure it is being removed properly."
            modTime = "The file /var/run/rsnapshot/ does not exits. No worries!"

    # Check for rsnapshot.conf syntax

    syntaxResult = commands.getoutput('/usr/bin/rsnapshot configtest')

    message = """From: %s
    To: %s
    Subject: Rsnapshot Checker


    This email is sent daily regardless.

    Rsnapshot.conf syntax: %s
    """ % (fromaddr, toaddr, modTime, syntaxResult)

    #if os.path.isfile("/var/run/"):
    s = smtplib.SMTP(server)
    s.sendmail(fromaddr, toaddr, message)

    • Arthur McLean
      Arthur McLean

      Okay, so clearly the formatting of the script above is messed up. All of the &quot should be changed to double quotes. And the 3 lines under IF and the 1 line under ELSE need to be tabbed in. Then it should work.

    • David Cantrell
      David Cantrell

      These forums aren't used very much, please use the rsnapshot-discuss mailing list.