General discussion

Locked

Need a quick Script

By pcammuso ·
I am not familiar with Unix Shell scripting so I was hoping someone could help me create a simple script.

I need to tar the entire contents of directory /usr/local/backup into a file.
I would like the file to be named
date_backup.tar (ie 06jun2000_backup.tar)
Then take that filename and compress it to a .Z file then move that filename onto another filesystem /disk1_backup

That's it! Also, if you could recommend a good, easy to understand Unix Shell Scripting Book.

For you guru's, I'm sure this isn't tough, so it's a quick way to get 250 points

Thanks
Paul

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Need a quick Script

by hugevlad In reply to Need a quick Script

Hello Paul,
Voila your script:
===== cut ======
#!/bin/sh
fname=/tmp/`date +%d%b%Y`_backup.tar
tar -cvf $fname /usr/local/backup
gzip $fname
cp $fname.gz /disk1_backup
rm $fname.gz
===== cut ======

Notes.
1. Make sure, that there is enough free space on file system with /tmp directory.
2. I use in my script gzip (GNU zip) program, which add ".gz" extention to the original name and remove original file. If you use other compress utilities, make appropriate changes.

About Unix Shell Scripting Book. I have read one little book (in Russian) and look throu douzen scripts, written by other people. This is a good way to learn shell scripting. Also, try search some books at O'Relly.

With best regards,
Vlad.

Collapse -

Need a quick Script

by pcammuso In reply to Need a quick Script

Vlad,

That was great! Thanks for the quick response.

Paul

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums