Menu

Cross-platform SnapRAID runner script with email support

Help
Chronial
2014-02-16
2021-02-26
1 2 > >> (Page 1 of 2)
  • Chronial

    Chronial - 2014-02-16

    Hi, I created a runner script for SnapRAID written in python. It should
    work on both windows and linux and supports sending emails and running
    scrub.

    You can get it here: https://github.com/Chronial/snapraid-runner/releases/

    Features
    • Runs diff before sync to see how many files were deleted and aborts if that number exceeds a set threshold.
    • Can create a size-limited rotated logfile.
    • Can send notification emails after each run or only for failures.
    • Can run scrub after sync

    Full readme here: https://github.com/Chronial/snapraid-runner/blob/master/README.md
    Any feedback is welcome :)

     
  • Anonymous

    Anonymous - 2014-02-16

    nice, works like a charm, thank you!
    can you implement that the script adds the date to the log and makes one log for every time you run it? and maybe define a seperate log folder where the logs get pushed to after the sync/scrub are finished.

    €: nevermind, i did just that with a little batch file that i run with the task scheduler to initiate the sync. :)

     

    Last edit: Anonymous 2014-02-16
  • robnitro

    robnitro - 2014-03-10

    No luck for me... tried changing the path with trailing slash and normal slash, python is in path, and I can't see what is wrong, maybe just the windows python interpreter sucks? Win 32, python 276
    running from command line as administrator with full rights...
    powershell script works (just crappy error detection right now)

    edit: just tried using the python 64 bit 2.7.6 same exact error.

    C:\snapraid\snapraidpython>python snapraid-runner.py
    2014-03-10 12:09:42,385 [INFO ] ===============================================
    =============
    2014-03-10 12:09:42,385 [INFO ] Run started
    2014-03-10 12:09:42,385 [INFO ] ===============================================
    =============
    2014-03-10 12:09:42,387 [INFO ] Running diff...
    2014-03-10 12:09:42,388 [ERROR ] Run failed due to unexpected exception:
    Traceback (most recent call last):
    File "snapraid-runner.py", line 190, in main
    run()
    File "snapraid-runner.py", line 212, in run
    diff_out = snapraid_command("diff")
    File "snapraid-runner.py", line 46, in snapraid_command
    stderr=subprocess.PIPE)
    File "C:\Python27\lib\subprocess.py", line 709, in init
    errread, errwrite)
    File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
    startupinfo)
    WindowsError: [Error 5] Access is denied
    2014-03-10 12:09:42,568 [ERROR ] Failed to send email
    Traceback (most recent call last):
    File "snapraid-runner.py", line 95, in finish
    send_email(is_success)
    File "snapraid-runner.py", line 80, in send_email
    server = smtplib.SMTP_SSL(**smtp)
    File "C:\Python27\lib\smtplib.py", line 781, in init
    SMTP.init(self, host, port, local_hostname, timeout)
    File "C:\Python27\lib\smtplib.py", line 251, in init
    (code, msg) = self.connect(host, port)
    File "C:\Python27\lib\smtplib.py", line 311, in connect
    self.sock = self._get_socket(host, port, self.timeout)
    File "C:\Python27\lib\smtplib.py", line 787, in _get_socket
    new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
    File "C:\Python27\lib\ssl.py", line 387, in wrap_socket
    ciphers=ciphers)
    File "C:\Python27\lib\ssl.py", line 143, in init
    self.do_handshake()
    File "C:\Python27\lib\ssl.py", line 305, in do_handshake
    self._sslobj.do_handshake()
    SSLError: [Errno 1] _ssl.c:507: error:140770FC:SSL routines:SSL23_GET_SERVER_HEL
    LO:unknown protocol
    2014-03-10 12:09:42,569 [ERROR ] Run failed

     

    Last edit: robnitro 2014-03-10
  • Chronial

    Chronial - 2014-03-22

    Are you sure you set the right path to the snapraid executable in your snapraid-runner.conf?

     
  • robnitro

    robnitro - 2014-03-30

    Thanks for the reply, I had the path there, but I didn't put the name of the file.
    The example didn't specify the snapraid.exe so I just put c:\snapraid
    As c:\snapraid\snapraid.exe it works now! Thanks.

     
  • Chronial

    Chronial - 2014-04-13

    Looking at the program this seems indeed rather unclear. I tried to clarify it and also make the error message more helpful.

     
  • JR A.

    JR A. - 2014-04-15

    I'm getting the same error message.

    The problem is that his SMTP server (like mine) is probably using a different SSL version or something.

    The issue is attempting to connect to the SMTP server to send the e-mail. Python is sending a command and the server is not understanding it.

     
  • JR A.

    JR A. - 2014-04-16

    Fix: if you're using Gmail's SMTP, make sure to use port 465.. I was using another port and it didn't like it.

     
  • Kryspy

    Kryspy - 2014-05-26
     

    Last edit: Kryspy 2014-05-26
  • Jens Bornemann

    Jens Bornemann - 2014-07-17

    Nice job :-)

    Will check it out and if I can merge snap shot support into it.
    My batch needs to move to python:
    https://sourceforge.net/p/snapraid/discussion/1677233/thread/5c9e670c/

    Cheers,
    Jens.

     
  • exodious2

    exodious2 - 2014-08-19

    I edit the snapraid-runner.conf.example and rename it to snapraid-runner.conf, but when I try to run the script i get:

    File "snapraid-runner.py", line 198
    print traceback.format_exc()
    ^
    SyntaxError: invalid syntax

    My snapRAID conf is located at /etc/snapraid.conf, with 777 permissions and nobody:nobody.

    I am using Arch with Python 3.4.1.

     
    • Mitchell Deoudes

      In python 3.0, print() is a function. Put parentheses around the rest
      of the line.

      There may well be other things that are broken, if the original script
      was written for Python 2.x, though. And not all of them will fail so
      obviously. I believe integer division changed, for example.

      You may be better off installing Python 2.x, unless someone wants to
      audit the code for compatibility.

      On 8/19/2014 2:54 PM, exodious2 wrote:

      I edit the snapraid-runner.conf.example and rename it to snapraid-runner.conf, but when I try to run the script i get:

      File "snapraid-runner.py", line 198
      print traceback.format_exc()
      ^
      SyntaxError: invalid syntax

      My snapRAID conf is located at /etc/snapraid.conf, with 777 permissions and nobody:nobody.

      I am using Arch with Python 3.4.1.


      Cross-platform SnapRAID runner script with email support


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/snapraid/discussion/1677233/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       
      • exodious2

        exodious2 - 2014-08-19

        Thanks for the help, I already have python2 installed. Not sure why I didn't try it out before you mentioned it.

        thanks!

         
  • John

    John - 2015-04-17

    FYI I think the exit codes changed in snapraid 8 and now snapraid-runner bails out with:

    [ERROR ] Command 'snapraid diff' returned non-zero exit status 1

    I'll try to find out more why/how they changed but if anyone is ahead of me please post :-)

     
  • Andrea Mazzoleni

    Hi John,

    Yes. In 8.0 the "diff" command will exit with error code 1 if a "sync" is required.

    Ciao,
    Andrea

     
  • Chronial

    Chronial - 2015-04-27

    Fixed: https://github.com/Chronial/snapraid-runner/releases/latest

    @andrea I love your tool, but are you really convinced that returning an error code is the right thing to do here? Now I have no way to detect errors in diff any more. If you can’t be convinced to undo this, could you maybe add a command line switch to disable this or return a specific error code in this situauton?

     

    Last edit: Chronial 2015-04-27
    • Fubduck

      Fubduck - 2015-04-28
       
    • Andrea Mazzoleni

      Hi Chronial,

      Yep, you are correct. In 8.1 I'll change it to use the return code 2 to report the "sync is needed" condition.

      Ciao,
      Andrea

       
  • JR A.

    JR A. - 2015-05-26

    Hi Chronial,

    Any chance you could update for 8.1?

    Thanks,

     
  • Mitchell Deoudes

    @Chronial (or anyone who's interested, really) - I've made some tweaks to the script:

    • ability to disable sync - for when you go on vacation, and just want it to keep scrubbing
    • a "smart" option, which runs the snapraid smart (disk health) function
    • defaulted the config file location to the location of the script, rather than the current directory
    • folded in the "exit codes" fix, above, so that it will run with snapraid 8.x. (It still just ignores exit codes. A better fix would make it read the code and handle '1' and '2' cases apropriately: 1 bombs out, 2 checks against the results of "diff" for consistency.)
    • all functions should default to the previous behavior, except where noted above

    Script and sample config are here: https://gist.github.com/meeotch/19e78a33b2e00d5d8ae6

    Sorry I couldn't be bothered to do this the right way by branching in git and issuing a pull request.

     
  • John

    John - 2015-08-27

    Thanks a lot, using it for the last few days. I noticed this (see my post above), then I fixed it myself, then Chronial fixed it as well and then snapraid changed again. Not that I'm complaining!
    Now I couldn't manage to sit down and change it again so thank you very much.

    Frankly something like this should be somehow by default included, I know snapraid tests if a mountpoint is empty but you can lose loads of files without knowing in many different ways (rsync --delete from a remote folder that happens to be empty at the time is just one of them, this actually happened recently, lucky I had also --backup). Right now if you simplu sync snapraid would just go: ok, I'll synchronize 350 000 deletese over all parities, all fine.

     
  • Chronial

    Chronial - 2016-04-02

    Bump.

    @Andrea I fell like this utility is getting lost in the forums, but I think it could be useful to a lot of people. Could you maybe link to it somewhere on the homepage?

     
    • Anonymous

      Anonymous - 2016-04-02

      i agree, best script out there. been using it since it came out, works like a charm. thanks again, Chronial!

       
  • John

    John - 2016-04-04

    I third that!

     
  • Chronial

    Chronial - 2017-07-20

    New minor release (v0.3): https://github.com/Chronial/snapraid-runner/releases/latest

    The script now limits the size of emails it tries to send out.

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.