- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- weekly backups of db exports - Scripting question
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-21-2005 02:56 AM
тАО10-21-2005 02:56 AM
Have a question to pose to the group, On a nightly basis my informix creates exports of our databases,
for each night there is 17 files, One night a week I want to create a CYA tape of the prior week's exports.
the Format of the file name is
`date +%Y%m%d`
I am wanting to create a backup scheme to roll these files out on a weekly basis to one weekly tape for the entire full week.
I want to build a test file using the ls command for STDIN to use in my `cat week##.log`
mt -f /dev/rmt/0m rew
tar -cvf /dev/rmt/0m `cat /restore/logs/week42.log` 2>&1 > /restore/4mmdat.log
I was assuming week## = `date +%W`,
and week## - 1 ( would be defined as
expr `date +%W` -1
mt -f /dev/rmt/0m rew
tar -cvf /dev/rmt/0m `cat /restore/logs/week42.log` 2>&1 > /restore/4mmdat.log
How would you do this scenario and make it fly. I am currently (manually) creating the "week##.log" files, I would like to parse and check "date +%Y%m%d` against "expr `date +%W` -1
So essential I need a process where I can build the "week##.log" the rest is fairly straight forward..
Any insight and suggestions appreciated as always.
Rex Mueller - Ed Svrc Unit #3
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2005 03:25 AM
тАО10-21-2005 03:25 AM
Re: weekly backups of db exports - Scripting question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2005 03:26 AM
тАО10-21-2005 03:26 AM
Re: weekly backups of db exports - Scripting question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2005 03:35 AM
тАО10-21-2005 03:35 AM
Solution(1)
I am under the impression that, you are going to run this out of cron once a week on the same day, and lets assume this day is Sunday.
Also I will assume the dB exports gets generated everyday including the weekends but your job will run after the exports complete for Sunday.
I think all you need to do is set what today's date is, as in :
TODAY=`date %Y%m%d` # this is Sunday
then use Clay's date hammer which can be obtained from:
http://mirrors.develooper.com/hpux/
(scroll to the bottom of the page for Date Hammer links)
Using this utility, figure out what the dates for Monday thru Saturday were, with respect to the $TODAY variable. Then the rest is pretty easy in my opinion.
LOGFILE=week$(date +%W).log
for day in $TODAY $SAT $FRI $THU $WED $TUE $MON
do
for dbname in $DBNAMES #set DBNAMES string prior to this point
do
echo ${day}${dbname}.tar.gz >> $LOGFILE
done
done
then use this as STDIN for your two-liner.
HTH
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2005 03:54 AM
тАО10-21-2005 03:54 AM
Re: weekly backups of db exports - Scripting question
I want to build a file either daily or one a cutoff day once a week, that I can use STDIN retaining the logfile as a catalog, whether it is with -mtime in a find string or ls..
currently my manual process is to create the log file, then read the file into a script.
I want to read into the script based on "CURRENT_WEEK" - 1 where log would be for
week42 reading the week41 log.
Say I cron the job on Sunday AM at 0600.
I've been playing with the date stuff, but my brain isn't working too well for a Friday. in addition to the normal distractions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2005 04:34 AM
тАО10-21-2005 04:34 AM
Re: weekly backups of db exports - Scripting question
I get a bunch of errors when I try to run the script on my UX system..
I think I am going to the following:
export wk=`date +%W`
export W=week"$wk"
tar -cvf /dev/rmt/0m `find /snapfileserver -name '*.tar.gz' -mtime -7 -print` 2
>&1 > /restore/"$W"dat.log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2005 05:37 AM
тАО10-21-2005 05:37 AM
Re: weekly backups of db exports - Scripting question
#place the caljd.sh script in a directory in the search path.
#mine is in /usr/contrib/bin
#
TODAY=$(caljd.sh)
(( DAY1=${TODAY}-1 ))
(( DAY2=${TODAY}-2 ))
(( DAY3=${TODAY}-3 ))
(( DAY4=${TODAY}-4 ))
(( DAY5=${TODAY}-5 ))
(( DAY6=${TODAY}-6 ))
DBNAMES="PERSONNEL SALES ACCOUNTS" # example for testing
LOGFILE=week$(date +%W).log
# if you are running the week's worth of files
# on Sunday, you are still in that calendar week
# as far as date command is concerned
for day in $TODAY $DAY1 $DAY2 $DAY3 $DAY4 $DAY5 $DAY6
do
td=`caljd.sh $day`
dayf=`echo $td|awk {'print $3'}``echo $td|awk {'print $1'}``echo $td|awk {'print $2'}`
for dbname in $DBNAMES
do
echo ${dayf}${dbname}.tar.gz >> $LOGFILE
done
done
The output I get from this right now is below:
# cat week42.log
20051021PERSONNEL.tar.gz
20051021SALES.tar.gz
20051021ACCOUNTS.tar.gz
20051020PERSONNEL.tar.gz
20051020SALES.tar.gz
20051020ACCOUNTS.tar.gz
20051019PERSONNEL.tar.gz
20051019SALES.tar.gz
20051019ACCOUNTS.tar.gz
20051018PERSONNEL.tar.gz
20051018SALES.tar.gz
20051018ACCOUNTS.tar.gz
20051017PERSONNEL.tar.gz
20051017SALES.tar.gz
20051017ACCOUNTS.tar.gz
20051016PERSONNEL.tar.gz
20051016SALES.tar.gz
20051016ACCOUNTS.tar.gz
20051015PERSONNEL.tar.gz
20051015SALES.tar.gz
20051015ACCOUNTS.tar.gz
HTH
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-17-2005 07:39 AM
тАО11-17-2005 07:39 AM