Page 1 of 1 1
Topic Options
#24080 - 2002-06-28 08:16 PM NTBACKUP SCRIPT
mikew50 Offline
Fresh Scripter

Registered: 2001-11-15
Posts: 17
Loc: NJ
I am trying to get this script to work. I have the 1st part working which runs NTBACKUP. But i cannot get the second part to work which goes out, gets the log file, renames it, and copies it to a designated place. Any help would be greatly appreciated.

Problem script:

; DATE : 6/28/2002
;
; COMMENT: Copies NT Backup log files to specified location, renames them to date of Backup
; ========================================================================
;Break on CLS
; ========================================================================
$server = "@WKSTA" ; Server name
$logdir = "\\$server\backup" ;Share where NTBACKUP log files exist
$logfile = "\\$server\backup\*.log" ;Logfiles
$logdest = "\\ocnfp2\it_share\backups ;Destination of log files
$buday = @MDAYNO" - "1"
; ========================================================================
;Rename log file
; ========================================================================
select
case exist ("$logdir\backup01.log")
shell '%comspec% /c ren "$logdir\backup01.log" "$buday @month @year.log"'
case exist ("$logdir\backup02.log")
shell '%comspec% /c ren "$logdir\backup02.log" "$buday @month @year.log"'
case exist ("$logdir\backup03.log")
shell '%comspec% /c ren "$logdir\backup03.log" "$buday @month @year.log"'
case exist ("$logdir\backup04.log")
shell '%comspec% /c ren "$logdir\backup04.log" "$buday @month @year.log"'
case exist ("$logdir\backup05.log")
shell '%comspec% /c ren "$logdir\backup05.log" "$buday @month @year.log"'
case exist ("$logdir\backup06.log")
shell '%comspec% /c ren "$logdir\backup06.log" "$buday @month @year.log"'
case exist ("$logdir\backup08.log")
shell '%comspec% /c ren "$logdir\backup08.log" "$buday @month @year.log"'
case exist ("$logdir\backup09.log")
shell '%comspec% /c ren "$logdir\backup09.log" "$buday @month @year.log"'
case exist ("$logdir\backup10.log")
shell '%comspec% /c ren "$logdir\backup10.log" "$buday @month @year.log"'
endselect

sleep 2

copy "$logdir\*.*" "$logsest"

sleep 1

del "$logdir\*.*"

exit

Top
#24081 - 2002-06-28 08:30 PM Re: NTBACKUP SCRIPT
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You're missing a quote on the line

$logdest = "\\ocnfp2\it_share\backups ;Destination of log files

and you have an odd number on the next one as well
$buday = @MDAYNO" - "1"
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24082 - 2002-06-28 08:39 PM Re: NTBACKUP SCRIPT
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
And furthermore...

the filespec for Exist() should be
case exist ($logdir + "\backup01.log")

One also must assume that "Backup" is a share name since you use UNC.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24083 - 2002-06-28 08:43 PM Re: NTBACKUP SCRIPT
mikew50 Offline
Fresh Scripter

Registered: 2001-11-15
Posts: 17
Loc: NJ
LLigetfa,
Thanks for the reply!
I am still stuck one the:
$buday = "@MDAYNO" - "1"

I am trying to get it to subtract one day before renaming the file. Does this look right to you. I am getting the error:
Script error : error in expression.!
Thanks again for the help. The more I learn about Kix I realize the more I need to know.

Top
#24084 - 2002-06-28 08:46 PM Re: NTBACKUP SCRIPT
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
I tested this and it works:

$buday = @MDAYNO - 1
_________________________
Dean

Top
#24085 - 2002-06-28 08:47 PM Re: NTBACKUP SCRIPT
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
...I'm trying to understand the logic of

$buday = @MDAYNO" - "1"

If you are trying to roll the number back 1 day, then it is flawed. Hell, it's flawed anyway. If doing math, don't put quotes around it. The flaw part is if @MDAYNO = 1 - 1 then it's 0.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24086 - 2002-06-28 08:50 PM Re: NTBACKUP SCRIPT
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I see Dean beat me to the draw. [Big Grin]

If the day is 0 then you have to roll the month back as well. If you are going to get that complex then check the UDF section for date math stuff.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24087 - 2002-06-28 09:01 PM Re: NTBACKUP SCRIPT
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You may want to consider using GetFileTime() instead. To get just the date portion try something like this:

Left(GetFileTime("C:\file.tst"),10)
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#24088 - 2002-06-28 09:04 PM Re: NTBACKUP SCRIPT
mikew50 Offline
Fresh Scripter

Registered: 2001-11-15
Posts: 17
Loc: NJ
All,
I see your point. Thanks again for your help. It worked like a charm. Here is the working script. Any comments? I am still a newbie at this.

; COMMENT: Copies NT Backup log files to specified location, renames them to date of Backup
; ========================================================================
;Break on CLS
; ========================================================================
$server = "@WKSTA" ;Server name
$logdir = "\\$server\backup" ;Share where NTBACKUP log files exist
$logfile = "\\$server\backup\*.log" ;Logfiles
$logdest = "\\ocnfp2\it_share\backups" ;Destination of log files
$buday = "@MDAYNO"
; ========================================================================
;Rename log file
; ========================================================================
select
case exist ($logdir + "\backup01.log")
shell '%comspec% /c ren "$logdir\backup01.log" "$buday @month @year.log"'
case exist ($logdir + "\backup02.log")
shell '%comspec% /c ren "$logdir\backup02.log" "$buday @month @year.log"'
case exist ($logdir + "\backup03.log")
shell '%comspec% /c ren "$logdir\backup03.log" "$buday @month @year.log"'
case exist ($logdir + "\backup04.log")
shell '%comspec% /c ren "$logdir\backup04.log" "$buday @month @year.log"'
case exist ($logdir + "\backup05.log")
shell '%comspec% /c ren "$logdir\backup05.log" "$buday @month @year.log"'
case exist ($logdir + "\backup06.log")
shell '%comspec% /c ren "$logdir\backup06.log" "$buday @month @year.log"'
case exist ($logdir + "\backup07.log")
shell '%comspec% /c ren "$logdir\backup07.log" "$buday @month @year.log"'
case exist ($logdir + "\backup08.log")
shell '%comspec% /c ren "$logdir\backup08.log" "$buday @month @year.log"'
case exist ($logdir + "\backup09.log")
shell '%comspec% /c ren "$logdir\backup09.log" "$buday @month @year.log"'
endselect

sleep 2

copy "$logdir\*.*" "$logdest"

sleep 1

del "$logdir\*.*"

exit

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1808 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.058 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org