Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script

Status
Not open for further replies.

meloadri

Technical User
Apr 7, 2009
120
US
Not sure where to post this but I created a batch file that looks like this: xcopy c:\Program Files\Microsoft SQL Server\MSSQL\Backup\cagpr\* \\cagnas\home\tstbkup\%date:~0,3%\* /Y /Q /S. I am trying to run this script from scheduled task but when I click on it, the screen just flashes and can't see what it did. I go to the destination and is empty. Basically, what I'm trying to do is back up the local SQL backup to a share drive on the network instead of doing a daily copy and paste. Can someone help please. Thanks
 
Put a pause at the end the script and it will stop so you can see the output.


RoadKi11

"This apparent fear reaction is typical, rather than try to solve technical problems technically, policy solutions are often chosen." - Fred Cohen
 
I did the pause thank you. I do get a message "invalid number of parameter". Not sure what that is. It does not have anything to do with backing up to the network right? \\cagnas is a NAS(Network Attached Storage)device.
 
Save as [.vbs] vbscript and see if this works.

Code:
Dim oShell:Set oShell = CreateObject("WScript.Shell")
Dim objDestinationPath, objSourcePath

objSourcePath = "c:\Program Files\Microsoft SQL Server\MSSQL\Backup\cagpr\*"
objDestinationPath = "\\cagnas\home\tstbkup\%date:~0,3%\"

copy = "XCOPY """ & objSourcePath & """ """ & objDestinationPath &  """ /Y /Q /S"
RunMe = copy
oShell.Run(RunMe)

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
xcopy "c:\Program Files\Microsoft SQL Server\MSSQL\Backup\cagpr\*" \\cagnas\home\tstbkup\%date:~0,3%\* /Y /Q /S

Note the quotes around the source path. The command processor sees a new parameter every time a space is encountered.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
It worked thank you. The following batch file was created by someone we have no contact with and it was suppose to be working and now it doesn't. Can you please explain what it does and maybe you can see something as to why it stop working? Thanks.

C:\WINDOWS\system32\NTBACKUP.EXE backup "@c:\batch\backup\data.bks" /n "65tyk21 Data Backup File" /d "65tyk21 Tuesday Backup" /v:no /r:no /rs:no /hc:eek:ff /m differential /j "data" /l:s /f "\\cagnas\backup\65tyk21\3_Tuesday\data.bkf"

del /Q "C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\BackupSave\*.bak"

move /Y "C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\*.bak" "C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\BackupSave\
 
Starts NT Backup
Code:
C:\WINDOWS\system32\NTBACKUP.EXE backup

Reads info from this saved file when backup job was saved
Code:
"@c:\batch\backup\data.bks" /n

Backup Name and Type of backup

[/code]
"65tyk21 Data Backup File" /d "65tyk21 Tuesday Backup" /v:no /r:no /rs:no /hc:eek:ff /m differential /j "data" /l:s /f
[/code]

Destination of backup
Code:
"\\cagnas\backup\65tyk21\3_Tuesday\data.bkf"

Deletes all backups quietly
Code:
del /Q "C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\BackupSave\*.bak"

Moves all backups
Code:
move /Y "C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\*.bak" "C:\Program Files\Microsoft SQL Server\MSSQL\BACKUP\BackupSave\"

MCITP:EA/SA, MCSE, MCSA, MCDBA, MCTS, MCP+I, MCP
 
Thanks. I guess there is nothing wrong with it since you did not specify it. I have a cheat sheet with some of the switches but do not have /rs, /hc, /j, /l:s...what do they stand for?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top