Checking rsync's integrity

2006-01-04
2012-12-11
  • Arthur McLean
    Arthur McLean
    2006-01-04

    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.

    #!/usr/bin/python
    import sys, smtplib, os, commands

    server = "mail.server.com"
    fromaddr = "mywebserver@my.server.com"
    toaddr = "me@server.com"

    # Check for PID file
    if os.path.isfile("/var/run/rsnapshot/rsnapshot.pid"):
            modTime = "Warning! The file /var/run/rsnapshot/rsnapshot.pid exists. It's mtime is "
            modTime += str(os.path.getmtime("/var/run/rsnapshot/rsnapshot.pid"))
            modTime += ". You should check to make sure it is being removed properly."
    else:
            modTime = "The file /var/run/rsnapshot/rsnapshot.pid 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

    %s

    This email is sent daily regardless.

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

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

     
    • Arthur McLean
      Arthur McLean
      2006-01-04

      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
      2006-01-12

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