Second attempt at this, which I have gone down a different and seemingly long winded route but I don't know what other way to do it.
Task -
Create a template (or skeleton) script for our backup scripts to sit inside.
Background -
We currently run our monthly (every 28 days) and weekly backups manually from the console every Saturday, be it weekly or monthly. We are looking to automate this so we don't need to be around!
Every 4 weeks (28 days) we have our monthly backups. This is the Saturday after our pay day. Sadly, this is not the first Saturday of the month since it's 4 weekly. Here is a few sample dates of Saturdays where we would run our monthly backups (note the last 2, since it's every 28 days we can have 2 monthly backups in 1 month):
- Saturday 24th July 2010
- Saturday 21st August 2010
- Saturday 18th September 2010
- Saturday 16th October 2010
- Saturday 13th November 2010
- Saturday 11th December 2010
- Saturday 8th January 2011
- Saturday 5th February 2011
- Saturday 5th March 2011
- Saturday 2nd April 2011
- Saturday 30th April 2011
What I have so far -
Basically the script I have made so far checks to see if it is a leap year. Then it checks if the lastbkup variable last went over the end of a year and minuses the days in the year so that it has the correct value for the new year. It then either runs a weekly script, or a monthly script depending on results.
The script actually seems to work fine, except for when it is a leap year. When it minuses 366 days, it should really be 365. The next year should minus 366 instead. Example of this -
For arguments sake it is Saturday 7th January 2012 which is day 7 of the year. It is a leap year. The last monthly backup was run 28 days ago, on the 10th December 2011 which is day 344 of the year (Handy day of the year calculator). The script adds 28 to this, to create the nxtbkup variable to get 372. Since it is a leap year it minuses 366 from this to get 6. Although this value should be 7. The script returns a weekly backup which should be a monthly one. Change the minus from 366 to 365? Well as far as I can work out the minus 366 needs to come in somewhere but I can't get my head around where or how it should come in. So I'm stuck! But apart from this, everything seems to work fine.
Files -
date4, date4.log, lastbkup
date4 contents -
Any help, comments, suggestions would be welcomed.
For arguments sake it is Saturday 7th January 2012 which is day 7 of the year. It is a leap year. The last monthly backup was run 28 days ago, on the 10th December 2011 which is day 344 of the year (Handy day of the year calculator). The script adds 28 to this, to create the nxtbkup variable to get 372. Since it is a leap year it minuses 366 from this to get 6. Although this value should be 7. The script returns a weekly backup which should be a monthly one. Change the minus from 366 to 365? Well as far as I can work out the minus 366 needs to come in somewhere but I can't get my head around where or how it should come in. So I'm stuck! But apart from this, everything seems to work fine.
I think that when you have incremented by 28 and your new value is greater than the number of days in last year you need to subtract the number of days in last year because the current year is now 2012.
In your example the 366 days will come into play when the incremented value rolls over into 2013 (by which time the current date must be in 2013).
Hi!
This sounds very complicated. Or maybe I haven't understood the problem description. But You want to run it EVERY fourth saturday?
Wouldn't it help to:
1) Schedule a cron job to run every saturday
2) let it read the "lastbkp" file where You have stored a backup counter
3) if it is four, do Your backup routine, write "1" to the file, and exit
4) if it is less than four, just increment it by one and write it back.
Can anyone explain what each line of the code does and how it works? I have no experience with python so I am not sure how the arrays and such work. I found this code while looking through the forums.
f = open("exams","r")
l = f.readline()
while l:
l = l.split(" ")
values = l
... (22 Replies)
Hi All,
I have written script and wanted to know the run time of it in seconds. i used below logic but am not getting the results in second instead getting error.
cat pkloader.sh
# if you want to calculate the time in milliseconds then use $(date +%s%N)
START_TIME=`date +%s`
echo... (2 Replies)
HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here
Im explaining the requirement of script.
AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Hi All,
I have the following time stamp data in 2 columns
Date TimeStamp(also with milliseconds)
05/23/2012 08:30:11.250
05/23/2012 08:30:15.500
05/23/2012 08:31.15.500
.
.
etc
From this data I need the following output.
0.00( row1-row1 in seconds)
04.25( row2-row1 in... (5 Replies)
Hi
This is the lspv output of my server :
cbspsdb01 #lspv
hdisk0 00c7518d2d512fd4 cdgvg active
hdisk1 00c7518d2dcbc9d6 cdgvg active
hdisk2 00c7518dcda9199a appvg active
hdisk3... (1 Reply)
I've tape which I've to use to restore data. The problem is that I don't know what type of backup I have on this type. Can someone help me and tell me how can I determine what type of backup is on the tape?
Thanks for your help. (2 Replies)
Hello all,
I'm totally new to UNIX/Linux but I'm taking a course in it at my local JC.
My question: I have been tasked with writing a gawk script that will create a nicely formatted report. That part I've done ok on...however, the very last thing that must be done is a calculation of a... (4 Replies)
Hi,
we are running solaris 9 on V280R. Due to power failure, one disk's label and lost its details like drive type etc.
Disk details:
<SUN72G cyl 14087 alt 2 hd 24 sec 424>
single partition on slice 6 with UFS.
The below i see when i run "format" command
.....
.....
4.... (1 Reply)