- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Create a Tar with date stamp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 02:35 AM
тАО10-27-2005 02:35 AM
I want to be a able to tar and then gz a file but I want to add a date stamp to the end of my file.
Exmp: fred.tar.gz.*Date* (day,month,year)
Thanks for the help!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 02:42 AM
тАО10-27-2005 02:42 AM
Re: Create a Tar with date stamp
http://www.hpux.ws/merijn/caljd.sh
It provides utility for getting dates into variables quite easily. Also calculations.
Install it and call it directly in your script that creats the tar
Then
filename="filename${day}${month}${year}.tar"
tar cvf $filename *
gzip $filename
Done.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 02:44 AM
тАО10-27-2005 02:44 AM
SolutionFNAME=fred.tar
tar cvf ${FNAME} . # create the tar archive
DT=$(date '+%d%m%Y')
NEW_FNAME="${$NAME}.${DT}"
gzip ${NEW_FNAME}
as a Plan B you could leverage the -S option of the gzip comand but agin I would put the date before the .gz
DT=$(date '+%d%m%Y')
SUF=".${DT}.gz"
gzip -S "${SUF}" fred.tar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 02:47 AM
тАО10-27-2005 02:47 AM
Re: Create a Tar with date stamp
tar -cvf
(assuming you are in correct directory)
gzip the tarball;
gzip
move the file to new name with date stamp;
mv
Can be done in fewer steps but this is the basic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 03:28 AM
тАО10-27-2005 03:28 AM
Re: Create a Tar with date stamp
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 03:37 AM
тАО10-27-2005 03:37 AM
Re: Create a Tar with date stamp
I did make one change. The end result that I am looking for is as follows:
05pIBM.date.tar
then I will do a gzip to make it:
05pIBM.date.tar.gz
Here is my current script which is not working. Thanks again for your feedback.
#!/bin/sh
$date=$(date '+%d%m%Y')
# create tarfile for /opt/IBM/05ptar
tar -cvf /tmp/05pIBM.$date.tar /opt/IBM
# end script
My file ends up looking like this:
05pIBM..tar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 03:43 AM
тАО10-27-2005 03:43 AM
Re: Create a Tar with date stamp
date=$(date '+%d%m%Y')
Rgds...geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 03:48 AM
тАО10-27-2005 03:48 AM
Re: Create a Tar with date stamp
your:
$date=$(date '+%d%m%Y')
should be:
DT=$(date '+%d%m%Y') # no dollar sign and it ain't too smart to use a variable name (date) that could easily be confused with a common command.
Also, it's wise to always enclose shell variables in {}'s. Most of the time they are not required to avoid parsing errors but sometimes they are. I hate code that branches (even inside my head) so I always use them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 03:57 AM
тАО10-27-2005 03:57 AM
Re: Create a Tar with date stamp
As you can see I am a major novice at this whole scripting thing.
My next piece to this puzzle is:
I am doing a scp of this file to another server and placing it in /adv/adm/backups.
I need to then create another script to remove the third archive in the /adv/adm/backups folder.
05pIBM.25102005.tar
05pIBM.26102005.tar
05pIBM.27102005.tar
I have tested my scp and that works great. Just not sure how to remove that first one and only leave two in the folder each day.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 04:04 AM
тАО10-27-2005 04:04 AM
Re: Create a Tar with date stamp
#!/bin/sh
# Script to remove old backup jobs
find /adv/adm/backups -name '05pIBM.*' -mtime +3 -exec rm {} \; >/tmp/rmoldbakup.log
Run from cron each day...
Rgds...geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 04:18 AM
тАО10-27-2005 04:18 AM
Re: Create a Tar with date stamp
You have really helped me out a ton..
Have great day !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2005 05:06 AM
тАО10-27-2005 05:06 AM
Re: Create a Tar with date stamp
Thanks to all...