Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A psync script that emails status reports UNIX
I have read much debate over the validity of psync here, but I have been using it to make backup copies of my user directory on my laptop for quite some time and have found it very useful.

I wrote this script that will run psync and then send you an email message summarizing what it mirrored or informing you that it failed -- for instance, if the drive you are backing up to is not present or the path names have been altered after the script is set up. I set up a cron job to run the script while I'm at lunch.

This works in OS X 10.4.1 with psync version 0.69.3.

[robg adds: I haven't tested this script. Remember to make it executable (chmod 755 script_name).]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[6,356 views]  

A psync script that emails status reports | 4 comments | Create New Account
Click here to return to the 'A psync script that emails status reports' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A psync script that emails status reports
Authored by: stuartlawson on Jun 03, '05 11:37:43AM
I think the code was messed up in the posting process. Don't use the code in the link in the main post. I'll try it again here:

#! /bin/sh
#-------------------------------------------------------------------------
# 2005 Stuart Lawson
# Works in OS X 10.4.1
# This script uses PSYNC
# PSYNC - Copyright 2002 Dan Kogai <dankogai@dan.co.jp>
# psync - 0.69.3  - get version from versiontracker.com
#-------------------------------------------------------------------------

#------- Edit variables here
#-------------------------------------------------------------------------
# User path to be archived
MYFILES="/Users";

# Path to volume where files wil be backed up
MYBACKUP="/Volumes/yourExternalHD/YourBackupFolder";

# Email address to send status report to after PSYNC is done
MYEMAIL="your.name@yourdomain.com";

# Message in email sent when PSYNC fails to run
FAILED="The PSYNC backup did not run because of an error. 
Either the backup external drive is not mounted 
or the file path names have been altered.";
#-------------------------------------------------------------------------

#------- Don't edit below here
#-------------------------------------------------------------------------
/usr/local/bin/psync -d $MYFILES $MYBACKUP >/psyncOut.txt;
if grep -c "copying items" /psyncOut.txt
then
tr '\r' '\n' </psyncOut.txt | grep [[:space:]]items[[:space:]] | mail -s "Backup script ran on ---->  `date`" $MYEMAIL;
rm /psyncOut.txt;
else
echo "$FAILED" | mail -s "Warning: Backup script FAILED on ---->  `date`" $MYEMAIL;
rm /psyncOut.txt;
fi
#-------------------------------------------------------------------------


[ Reply to This | # ]
A psync script that emails status reports
Authored by: demmons65 on Jun 07, '05 08:21:31PM

Is there any Tiger-specific code in this that would prevent it from running on a Panther system? (presuming the same version of psync is installed.)



---
d a v e

http://www.hostwerks.com/~dave/



[ Reply to This | # ]
A psync script that emails status reports
Authored by: adamjohnson on Jun 11, '05 01:35:28PM

I'm curious about this too. Specifically about the 'mail' command, was it available in 10.3?



[ Reply to This | # ]
A psync script that emails status reports
Authored by: stuartlawson on Jun 28, '05 09:49:19AM

I had used it in 10.3 before upgrading o 10.4 and it worked.

If you compare the MAN pages for "mail" in 10.3 and 10.4, "mail" in 10.4 has a few more features, but it works the same in both.




[ Reply to This | # ]