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

Back up Entourage data files automatically Apps
I use Entourage for email, news and for syncing with my Palm. I needed a way to backup the user area automatically to a single file so that I could use Backup to put that file to my idisk.

I decided to use shell scripting and make use of the /etc/daily script that is called from cron via periodic. My script could be expanded and could be used on an XServe with multiple users. A System Admin could use this script to automatically create single file backups of their users' Entourage data in their home directories.

Here is the code as appended to the end of /etc/daily.
#
#Checking if Entourage is up and creating backup
#
ent_up=`ps ax | grep Entourage | grep -v grep | wc -l`
if [ $ent_up -gt 0 ]; then
  echo ""
  echo "Entourage is currently running - backup aborted"
  exit 1
fi
for user in [user1] [user2]
do
  echo ""
  echo "Creating New MSData file for $user"
  cd /Users/$user/Documents
  tar -cf $user_MSData.tar "Microsoft User Data"
  gzip -f $user_MSData.tar
  chown $user MSData.tar.gz
  echo "Finished Creating Entourage Backup for $user"
done
If you have lots of users or your usernames change, change the for users in line to:
for users in `ls /Users | grep -v Shared`
Of course, if you are on an Xserve, some people may not use Entourage, so you could always do a check for the directory /Users/username/Documents/Microsoft User Data directory and if it exists, then do the tar.

If you want to go further, you could do a find on *MSData.tar.gz and move those files to a central storage area to be backed up later. This way, you automatically backup all users' Entourage data daily, no matter how many users you have, and you don't have to worry about users being added / deleted. The command could be:
find /Users -name "*MSData.tar.gz" -exec mv {} /backup ;
[robg adds: I have not tested this script.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,851 views]  

Back up Entourage data files automatically | 6 comments | Create New Account
Click here to return to the 'Back up Entourage data files automatically' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Warning!!!
Authored by: cyber.sonik on Jul 07, '03 12:48:53PM

This script does not take into account resource forks. The tar command will strip these from any file that includes one. Having just tested the script, some files were affected.



[ Reply to This | # ]
Warning!!!
Authored by: mervTormel on Jul 07, '03 08:10:51PM

true. one should use a rezFork friendly tool like ditto or rsync



[ Reply to This | # ]
hfstar or hfspax
Authored by: extra88 on Jul 07, '03 11:17:22PM
I don't know how important resource forks actually are to Entourage data files but neither of those programs do what tar does, namely combine multiple files into a single file.

Instead, tar should be replaced with either hfstar or hfspax. I like hfspax but hfstar may be preferable because you wouldn't have to make any changes to the script, just symlink hfstar to tar (actually when you compile and install it, it is named "tar" and is put in /usr/local/bin/).

On a separate note, if you add the "-z" switch to tar (just change "-cf" to "-zcf" and the destination file to end with .tgz) you could cut the gzip line, tar will automatically zip the resulting tar file.



[ Reply to This | # ]
Back up Entourage data files automatically
Authored by: mervTormel on Jul 07, '03 08:07:35PM

this kind of op should be put in /etc/daily.local so that it survives subsequent OS updates.

examine /etc/daily and you see a callout to /etc/daily.local - it's what it's there for.



[ Reply to This | # ]
Back up Entourage data files automatically
Authored by: ukkarhu on Jul 09, '03 12:17:12PM

Thanks for that. I'm from a UNIX background (AIX and Solaris) so am not used to the way Apple uses cron so I'll bear this in mind. I did know about resource forks but didn't think Entrourage used them - again I may be wrong on this.

Thanks for the advice, I'll bear this in mind with future scripts I write.

Andy



[ Reply to This | # ]
Back up Entourage data files automatically
Authored by: gatorparrots on Jul 15, '03 09:12:07PM
#!/bin/sh
##
# This script will backup the Entourage mail database to second location
# for seven days, removing older depreciated backups and starting anew
# Suggested usage: run nightly with cron
##
#initialize variables
username="$(who | grep console | awk '{print $1}')"
if [ "$username" = "" ]; then
    echo "No one logged in via GUI (console)" >&2
    exit 1
fi
userhome="$(eval echo ~$username)"
date=$(date +%Y.%m.%d)
backupdir="/Volumes/documents/backup/Entourage"
#clean up last week
if [ $(cd $backupdir && 'ls' -1 | wc -l) == 7 ]; then
	rm -rf $backupdir/*
fi
#Quit Entourage and give it time to write its database to disk
/usr/bin/osascript -e 'tell application "Microsoft Entourage" to quit'
/bin/sleep 5
#Copy the data & create a log
mkdir $backupdir/Entourage-$date
echo $date > $backupdir/backup.log
/usr/bin/ditto -rsrc -V "$userhome/Documents/Microsoft User Data/Office X Identities/Main Identity" "$backupdir/Entourage-$date/Main Identity" >> "$backupdir/backup.log"
echo "Backup successful" >> $backupdirp/backup.log
mv "$backupdir/backup.log" "$backupdir/Entourage-$date/backup.log"
#Relaunch Entourage
/usr/bin/osascript -e 'launch application "Microsoft Entourage"'


[ Reply to This | # ]