I haven't tested this, but this should do what you want:
#!/bin/sh
USER=bryce
NFSMOUNT=somenfsmount
FILENAME=somefilename
COMPUTERNAME=`uname -n`
DATE=`date +%m-%d-%y`
DIRECTORYTOBU=somedirectorytobu
su $USER -c "cd /home/$USER; tar czf \
$NFSMOUNT/$FILENAME.$COMPUTERNAME.$DATE.tar.gz $DIRECTORYTOBU/"
On 13 Apr 2002, Bryce C. wrote:
> Hi,
> Could anyone give me some help with some bash scripting. I'm trying to
> write a script for an hourly back up but I don't know how to add a
> timestamp in to the tar output file name. What I have currently (with
> confidential parts hidden) is:
>
> #!/bin/bash
> su _USER_ -c "cd /home/_USER_; tar -czf
> _NFSMOUNT_/_FILENAME_._COMPUTERNAME_._DATE_.tar.gz _DIRECTORYTOBU_/"
>
> Anything with _TEXT_ is the ommitted text except for the _DATE_. Anyone
> please?
>
>
>
>
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list - PLUG-discuss@lists.plug.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>