Web Development

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion


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


This conversation is currently closed to new comments.

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 ======
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 ======

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,

Collapse -

Need a quick Script

by pcammuso In reply to Need a quick Script


That was great! Thanks for the quick response.


Related Discussions

Related Forums