SunQuest
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old December 2nd, 2003, 12:29 AM
ajrandrup ajrandrup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 ajrandrup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ajrandrup Send a message via Yahoo to ajrandrup
Exclamation help in creating script to make tar file

hello, im a newbie in unix scripting. can someone pls send me a sample script that will tar files in the folders of a specific directory, but will exclude specific files, and afterwards, will ftp the tar into another server.

for example:
in this directory, pshrprod:/opt/psoft/weblogic/818sp9_80

the following files and folders will be tar'd (this are not all the files/folders in this directory)

copyright.html
license.txt
license.html
classes --this folder also has files inside--
src

but will exclude these files in these directories:

Please exclude (aonprod08)pshrprod:/opt/psoft/weblogic/818sp9_80/psftaccess.log and /opt/psoft/weblogic/818sp9_80/myserver/access.log

my question is: if the files will be tar'd where will the tar file be located?

also, can the specific date and time of the run of the script be included?

hope someone out there replies to me ASAP.

thanks a lot

Reply With Quote
  #2  
Old December 2nd, 2003, 12:29 PM
druuna druuna is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 137 druuna User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 37 sec
Reputation Power: 0
Re: help in creating script to make tar file

Quote:
send me a sample script that will tar files in the folders of a specific directory, but will exclude specific files, and afterwards, will ftp the tar into another server.

The --exclude-from=FILE option that is part of tar is one option.

$ tar cf some.tar --exclude-from=/some/path/exclude_me *

This will tar all (* at the end) except for the files mentioned in/home/joe/exclude_me. Under unix/linux, the term 'files' also include directories.

So if you put these two lines:

/opt/psoft/weblogic/818sp9_80/psftaccess.log
/opt/psoft/weblogic/818sp9_80/myserver/access.log

inside a file and use tar with the --exclude-from=file option, these wioll not be tarred.
Quote:

my question is: if the files will be tar'd where will the tar file be located?

Where you tell it to:

$ tar cf /data/backup/todays_backup.tar *
todays_backup.tar is placed in /data/backup/

$ tar cf todays_backup.tar *
todays_backup.tar is placed in present working directory

See man tar for more options/explanations.
Quote:

also, can the specific date and time of the run of the script be included?

The date command can give you just about any date format you can think of.

$ date '+%d%m%Y'
02122003

Prints present day, month and year.

Put this in a variable and use that to create the name of your tarred file.

#!/bin/bash
# Fill variable with current day, month and year (ddmmyyyy)
DATESTAMP="`date '+%d%m%Y'`"
# tar everything in current directory and put this into a file with current date attached to it and place this file in /tmp
tar cf /tmp/todays_backup.tar.${DATESTAMP} *

This should be enough to get you going :-)

Reply With Quote
  #3  
Old December 3rd, 2003, 12:43 AM
ajrandrup ajrandrup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 ajrandrup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ajrandrup Send a message via Yahoo to ajrandrup
is it also possible to include in the script something that will make it run at a specific day and time?

thanks!

Reply With Quote
  #4  
Old December 3rd, 2003, 01:15 AM
mttatkns mttatkns is offline
Got source?
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2003
Location: Laguna Niguel, California, USA
Posts: 2,332 mttatkns User rank is Private First Class (20 - 50 Reputation Level)mttatkns User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8

Reply With Quote
  #5  
Old December 9th, 2003, 12:15 AM
ajrandrup ajrandrup is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 4 ajrandrup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to ajrandrup Send a message via Yahoo to ajrandrup
hello again, follow up question on the 1st reply:
how do i open a tar file? its a simple file.tar that i need to open.
thanks a lot

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > help in creating script to make tar file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway