Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Small Python script to check last directory update time and email
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Small Python script to check last directory update time and email

Hello,

I recently got into a problem where checking multiple directories if they are updated with backups regularly was becoming a hassle. Couldn't find exact script so wrote down one. Sharing because maybe someone can use it(?)

Link: https://gist.github.com/jetchirag/2465e91eec87aff9b4ff032b647c388b

It wouldn't fit for many use case but seems to work for me. Would love to hear suggestions :D

Thanks

Thanked by 1ehab

Comments

  • jarjar Patron Provider, Top Host, Veteran
    edited January 2018

    Backup script screwed up but still triggered update time on directory, this check leaves you under the impression that the backup succeeded. I would instead have the backup script check that the file it was supposed to create is indeed where it should be, and that it has a size greater than X (where X is a number you expect it to always be greater than), then send you an email.

    On one hand it relies on the same script you want to check up on, on the other hand a failure of that script to run entirely would show in the lack of a report.

    The last thing you want is to find out months down the road that backups were failing and you thought they were working. Been there many times due to rolling my own scripts and screwing up logic.

    Thanked by 3spammy jetchirag WSS
  • jarland said: Backup script screwed up but still triggered update time on directory

    That's something I meant with

    jetchirag said: It wouldn't fit for many use case but seems to work for me.

    What I may do to overcome this problem is to update another file which will keep record of directory size on last run. (However sometime size calculation on backup server is disabled to prevent unnecessary load). There will still be many problem per me if this method is used like false alarms on backup rotation etc.

    Thanked by 1jar
  • i have a script that after backup it touches a file called LastSync with backup time stamp. Then i use the wonderful rsync to compare if remote is newer this way rsync -aumn --info=NAME

    there is an if condition to continue backup or just tell "remote can be newer" ...

    Thanked by 2raindog308 jetchirag
  • @ehab said:
    i have a script that after backup it touches a file called LastSync with backup time stamp. Then i use the wonderful rsync to compare if remote is newer this way rsync -aumn --info=NAME

    there is an if condition to continue backup or just tell "remote can be newer" ...

    This server for which I wrote this is generally (S)FTP only. The backup server has no control over the sender or original server!

    I might do some with number of files & directory on account which may be a working option but will add unnecessary load to this mini server.

  • raindog308raindog308 Administrator, Veteran

    ehab said: i have a script that after backup it touches a file called LastSync with backup time stamp.

    This is how I do it as well.

    For example, on some servers I want to do a pre-backup capture (e.g., dump config, db dumps, etc.) The script running that job touches a file at the end. If the backup comes along and doesn't see that file (or sees it's > X hours), it waits until the file is present, eventually timing out with an error if it doesn't show up. Very common logic.

  • @raindog308 said:

    ehab said: i have a script that after backup it touches a file called LastSync with backup time stamp.

    This is how I do it as well.

    For example, on some servers I want to do a pre-backup capture (e.g., dump config, db dumps, etc.) The script running that job touches a file at the end. If the backup comes along and doesn't see that file (or sees it's > X hours), it waits until the file is present, eventually timing out with an error if it doesn't show up. Very common logic.

    Sorry @ehab, I think I misunderstood that line. It sounds much better this way. Would try soon :D

Sign In or Register to comment.