Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Backup Script-copy

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,41914
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Backup Script-copy
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2] 3   next >   >>
Login
Message << Older Topic   Newer Topic >>
 RE: Backup Script-copy - 1/12/2007 4:50:44 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
Hi, dm_4ever

I fixed 2 things with these lines, 1) replaced filesys with fso, 2) added the sub folder name to the path.

I do have q question, regarding the dim and const, so if you use a const statement, you do not need a dim statement to hold the value?

I just need to figure out why it is not deleting files that are older then 7 days. I even rename the file name in
If fso.FileExists("c:\DenServerBackup\Sunday\Sunday.bkf") Then, to this If fso.FileExists("c:\DenServerBackup\Sunday\SUNDAY20070111.bkf") Then

and still did not delete it, so I guess my problem is in this line of code:

      

Then maybe EBGreen can help me with the adding the date code to the file name to be checked, as my script looks for Sunday.bkf and not For
SUNDAY20070111.bkf, and I do not even have a clue, about adding this to the vbs code.

Here is the fixed code:


      


Thanks,

Mike

< Message edited by netman06 -- 1/12/2007 4:52:43 AM >

(in reply to dm_4ever)
 
 
Post #: 21
 
 RE: Backup Script-copy - 1/12/2007 4:56:12 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Try this code:


      

It should take care of making sure only files from the last 7 days are present. Note that this means just 1 file in each of the day folders. 

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dm_4ever)
 
 
Post #: 22
 
 RE: Backup Script-copy - 1/12/2007 5:26:24 AM   
  dm_4ever


Posts: 2313
Score: 34
Joined: 6/29/2006
From: Orange County, California
Status: offline
I think this line needs to be changed.

from:  CleanUpOldFiles oFSO.GetFolder(dicDays(strDay), 7)

to:  CleanUpOldFiles oFSO.GetFolder(dicDays(strDay)), 7

I enjoy seeing how people like ebgreen, ehvbs, tno, and many more are able to streamline certain processes....I'm always learning something new from all of you.

< Message edited by dm_4ever -- 1/12/2007 5:29:25 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 23
 
 RE: Backup Script-copy - 1/12/2007 5:42:00 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Oops...thanks for the catch. My compiler-like brain is asleep at the wheel today. I apologize for the mistake, but I am not testing any of this code (busy day) and am basically just brain dumping it onto the page.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to dm_4ever)
 
 
Post #: 24
 
 RE: Backup Script-copy - 1/12/2007 9:23:50 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
HI, EBGreen

Wow, awesome.

I do have a question, if I perform a full on mon, diffs, tue,wed, thur, fri, sat, sun. Shouldn't I have a maybe two. I was trying to figure this out earlier when I used 7 days, and I thought was better then giving it a full weeks worth of runs.

Any ideas

Thanks so much for all of your help, and like dm_4ever said, you can sure learn from people like you, even with you coding, I always look at how you do it, so next time I can look up the commands, which I helpful, but a lot of times, its really hard to put everything together, which I guess takes all of tweaking and reading posts, and helpful people like yourself and dm_4ever.

Thanks, Guys

(in reply to ebgreen)
 
 
Post #: 25
 
 RE: Backup Script-copy - 1/18/2007 2:32:37 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
hello,

I transfered this script to Windows Server 2003, and now I'm receiving this error message.

It worked fine on Windows xp Service pack 2. I have look up error 800A0046, but have not found a solution.

Error is saying Permission denied, line 31 and Char 1. I have set every dir and file to administrator full control, with no luck. I know it has something to do with server 2003, but what.

This is the line that is having trouble:

      



      


Thanks,

Mike




Thumbnail Image


Attachment (1)

(in reply to netman06)
 
 
Post #: 26
 
 RE: Backup Script-copy - 1/18/2007 2:57:04 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
That is one of the problems with complex lines like that. It is hard to determine exactly what instruction in the line causes the error. Try putting these lines right before the problem line to see if we can narrow down the error source.

WScript.Echo oFile.Name
WScript.Echo oFSO.GetBaseName(oFile.Name)
WScript.Echo GetTimeSatmp(oFile)
WScript.Echo oFSO.GetExtensionName(oFile.Name)


Oh, as something of a prediction, I would expect this error to be related to the rights on a specific file.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to netman06)
 
 
Post #: 27
 
 RE: Backup Script-copy - 1/18/2007 3:41:25 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
HI,
EBGreen

Here is the information, it all looks good to me.

WScript.Echo oFile.Name
Friday.bkf 
WScript.Echo oFSO.GetBaseName(oFile.Name)
Friday
WScript.Echo GetTimeSatmp(oFile)
20070112
WScript.Echo oFSO.GetExtensionName(oFile.Name)
bkf

Then I get the error:








Thumbnail Image


Attachment (1)

(in reply to ebgreen)
 
 
Post #: 28
 
 RE: Backup Script-copy - 1/18/2007 3:45:22 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
well that tells us that the issue is purely related to the copy command. Get rid of those echo statements and put this right before the problem line:

If oFSO.FileExists(dicDays(UCase(oFSO.GetBaseName(oFile.Name))) & oFSO.GetBaseName(oFile.Name) & GetTimeStamp(oFile) & "." & oFSO.GetExtensionName(oFile.Name)) Then
   WScript.Echo dicDays(UCase(oFSO.GetBaseName(oFile.Name))) & oFSO.GetBaseName(oFile.Name) & GetTimeStamp(oFile) & "." & oFSO.GetExtensionName(oFile.Name) & " EXISTS ALREADY!"
End If

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to netman06)
 
 
Post #: 29
 
 RE: Backup Script-copy - 1/18/2007 4:04:45 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
Hi, EBGreen

Here is what that produced.





Thumbnail Image


Attachment (1)

(in reply to ebgreen)
 
 
Post #: 30
 
 RE: Backup Script-copy - 1/18/2007 4:36:19 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Change this:

oFile.Copy dicDays(UCase(oFSO.GetBaseName(oFile.Name))) & oFSO.GetBaseName(oFile.Name) & GetTimeStamp(oFile) & "." & oFSO.GetExtensionName(oFile.Name)


to this:

oFile.Copy dicDays(UCase(oFSO.GetBaseName(oFile.Name))) & oFSO.GetBaseName(oFile.Name) & GetTimeStamp(oFile) & "." & oFSO.GetExtensionName(oFile.Name), true

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to netman06)
 
 
Post #: 31
 
 RE: Backup Script-copy - 1/18/2007 5:10:07 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
still getting the same error message. What happens, different in Windows Server 2003 and Windows XP SP2, reference scripting and permissions, because it worked great on Windows XP, but not on Windows Server 2003?

Thanks,

Mike

(in reply to ebgreen)
 
 
Post #: 32
 
 RE: Backup Script-copy - 1/18/2007 7:05:26 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
The true option tells the copy to overwrite the file if it already exists. So it sounds like your script does not have the rights to do so.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to netman06)
 
 
Post #: 33
 
 RE: Backup Script-copy - 1/18/2007 1:22:58 PM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
HI, EBGreen

I think I figure out the problem, it has something to do with the sourcedir line. I had it set to "G:\\", so I tried it with "G:\BackupTest\", and I did not get the error. I'll give you an update after somemore testing.

Your orignal line:

Const SOURCEDIR = "C:\Path\To\Dir\Den_Server_Backup\" 'Note the trailing \

EBGreen, I'm trying to get dm_4ever code to work with your code. I will first your your script, then run dm_4ever code, for deleting files older then seven days, but I do not have any idea how to work with the file names, because of the date include in the file name, I have tested it with just standard days of the week names, like monday, sunday, and it works, so how can it work with Friday20070118.bkf, if It is not possible, what if we used on the file extention, which we know, like is there a way to use just *.bkf.

Here is the code:


      

Thanks for all of your help today, trying to get this to work, it really must be a root drive thing on Windows server 2003?

Mike

(in reply to ebgreen)
 
 
Post #: 34
 
 RE: Backup Script-copy - 1/18/2007 6:05:31 PM   
  gdewrance


Posts: 587
Score: 3
Joined: 3/16/2006
Status: offline
If you having issues with IF End IF and Next, I would start by reading this great book.
After an hour you will know exactly what ebgreen etc are writing

Microsoft Windows Scripting Guide[link=http://www.avaxhome.ru/ebooks/0735618674asd.html#][/link]
http://www.avaxhome.ru/ebooks/0735618674asd.html

(in reply to netman06)
 
 
Post #: 35
 
 RE: Backup Script-copy - 1/19/2007 2:21:13 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Go back and look at some of my previous posts. In one of them I included a Sub that will delete files older than 7 days in the backup folder.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to gdewrance)
 
 
Post #: 36
 
 RE: Backup Script-copy - 1/19/2007 2:23:59 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
Thanks, qdewrance

Mike





(in reply to ebgreen)
 
 
Post #: 37
 
 RE: Backup Script-copy - 1/19/2007 3:15:41 AM   
  netman06

 

Posts: 103
Score: 0
Joined: 10/19/2006
Status: offline
HI, EBGreen

I have added the liines, but I'm getting an error message. 800A01C2, I looked it up and here is it said, regarding the error,

Troubleshooting Error 800A01C2 - Wrong number of arguments of invalid property assignment.
Error 800A01C2 is a tricky problem.  Check to see if your script needs an extra 'Set' Command
Introduction to Code 800A01C2
Error code, 800A01C2 occurs when you execute a VBScript.  This is a runtime error, therefore check the names of your objects. 
The Symptoms you get
The script does not execute as you had hoped. Instead you get a message box like this picture:  (If you have a better screen shot, then please email me.) 
The Cause of Code 800A01C2
The best clue to the error comes at the end of the line, the word 'objUser'.  objUser is a valid object and term, therefore we need to investigate what is missing.  I solved the problem by comparing with another script, which executed perfectly.  It turned out that 'Set' was required in front of objUser.
Incidentally, Source: reports a runtime error not a compilation error, this means you are looking not for a pure syntax problem, but a fault logic error.  In the case of runtime errors, you can use this temporary work around.  Add this statement just before the line which errors: On Error Resume Next.
The Solutions Wrong number of arguments of invalid property assignment.
Check the names in your script, pay particular attention to object names.  Note: The Line: 6 Char: 1  In this case it is not Char 1 to blame, more that there is something wrong and none of the line can execute.  In this case it should be Set objUser =
As a last resort, in the case of runtime errors, you can add this line:
On Error Resume Next.

EBGreen, I set a wscript.echo for the (strday), string but it contained a null value.

above this code

For Each strDay In dicDays.Keys()
CleanUpOldFiles oFSO.GetFolder(dicDays(strDay), 7)
Next

Error is on Line # 24 , Char 4

Wrong number of arguments or invaild property assignment: 'getfolder'

so if it needs a set command. so would this line need a set command.

For Each oFile In oFSO.GetFolder(SOURCEDIR).Files
 
Also, I pretty sure now that the script does work, now that I figure out the root drive issue.

Thanks again for all of your time you put into this script and giving me a opportunity to learn more about vbscripting, I know we are close now to figuring out a great script, the hopfully forums users can use for the same propise as me.

Mike


Thumbnail Image




      

Attachment (1)

< Message edited by netman06 -- 1/19/2007 3:18:47 AM >

(in reply to netman06)
 
 
Post #: 38
 
 RE: Backup Script-copy - 1/19/2007 3:23:26 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
So if you change this:

For Each strDay In dicDays.Keys()
CleanUpOldFiles oFSO.GetFolder(dicDays(strDay), 7)
Next

to this:

For Each strDay In dicDays.Keys()
WScript.Echo strDay & " - " & dicDays(strDay)
CleanUpOldFiles oFSO.GetFolder(dicDays(strDay), 7)
Next


You get an empty string for strDay??

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to netman06)
 
 
Post #: 39
 
 RE: Backup Script-copy - 1/19/2007 3:27:46 AM   
  ebgreen


Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
Also, let me make sure that I understand your archiving needs. You want to have this:

ARCHIVEFOLDER
   |
   |---MONDAY
           |--FIle that is 1 day old
           |--File that is 2 days old
                      .
                      .
                      .
           |--File that is 7 days old
   |---TUESDAY
             .
             .
             .
   |---SUNDAY

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 40
 
 
Page:  <<   < prev  1 [2] 3   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.