Creating Scripts

I am not Unix guru, so I need a little help here please. I have created two simple scripts, one which will basically backup a data directory onto a cdrw,the other will restore the directory from the cdrw. However, as the scripts are for my customer site, I would like to amend them to add a date stamp on the created file that gets burnt onto the cdrw. And would like the restore script to be able to recognise a date stamp to pull the files of the cd. Is there a way of creating arguments to do this please?

----------------------------

We could be a lot more help if you shared the script you are currently using. Are you creating a tar file and copying it to the cdrw ? Are you creating a iso image and burning that ?
var=`date +%Y%m%d`

----------------------------

Thnaks for the quick reply,I knew I should have put this on the first time around, the scripts are as follows:
Backup script
cd /usr/lsrc/wanadmin
tar cvf data_backup.tar /usr/lsrc/wanadmin/data
tar tf data_backup.tar > archive.lst
mkisofs -r data_backup.tar archive.lst 2>/dev/null | cdrw -i
rm -rf data_backup.tar
rm -rf archive.lst
Restore Script
cp /cdrom/cdrom0/data_backup.tar /usr/lsrc/wanadmin
cd /usr/lsrc/wanadmin
tar xvf data_backup.tar /usr/lsrc/wanadmin/data
rm -rf data_backup.tar

----------------------------

The output of
tar tvf filename.tar

will show you the modification times of the files contained in the tarball. You should be able to grep for the file you would like to restore and compare the mod times to the current one on the host.

If you just want the name of the tarball to include the time

tar cvf `date +%Y%m%d`.tar /source/directory

BTW you don't need to copy from the CD before doing the extract

tar xvf /cdrom/cdrom0/data_backup.tar /usr/lsrc/wanadmin/data

----------------------------

But this still didnt achieve what I was aiming for. I tired the following command:
tar cvf `date +%Y%m%d`.tar /source/directory

And all the system did was to create a tarfile called `date +%Y%m%d`.tar and not put a date/time stamp which I wanted to do, as I explained I am a total Unix novice and have never been trained in the OS at all.

----------------------------

> all the system did was to create a tarfile called `date +%Y%m%d`.tar
Strange. Are you sure those were backticks and not regular quotation marks?

You could also try the alternative $() notation (ksh and bash) which does the same thing, i.e:

tar cvf $(date +%Y%m%d).tar /source/directory

----------------------------

Ahhh, that will explain it, well I will try it out once more when I get the chance....and many thanks for the advice.

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.