July 17, 2012 at 8:59 am
Hi All
How would I setup a script to copy files from a shared location on one server, to a shared location on another server?
The extension of the files would be .trn
I assume that I would need to use xp_cmdshell
Thanks
July 17, 2012 at 9:03 am
SQLSACT (7/17/2012)
Hi AllHow would I setup a script to copy files from a shared location on one server, to a shared location on another server?
The extension of the files would be .trn
I assume that I would need to use xp_cmdshell
Thanks
No, you could use a VBscript or even a powershell script and run as a sql server agent job step, no XP_CMDSHELL needed here
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
July 17, 2012 at 9:53 am
SQLSACT (7/17/2012)
Hi AllHow would I setup a script to copy files from a shared location on one server, to a shared location on another server?
The extension of the files would be .trn
I assume that I would need to use xp_cmdshell
Thanks
You could use the xp_cmdshell for this with a command that looks a little like this:
EXEC xp_cmdshell 'copy *.trn WHEREEVER/trn_backups';
The xp_cmdshell is not the best choice for something like this though.
The way to go is to:
1) Create a new SQL Server job (say named, "copy transaction log files")
2) Add a step with type Operating System (cmdExec)
3) Add this to the command area:
copy *.trn WHEREEVER/trn_backups'
4) Schedule the job to run whenever you wish
-- Itzik Ben-Gan 2001
July 17, 2012 at 10:03 am
I would use a Powershell Script for this. Flexible and easy to change, if required.
If you need help with it let us know.
July 17, 2012 at 1:20 pm
OTF (7/17/2012)
I would use a Powershell Script for this. Flexible and easy to change, if required.If you need help with it let us know.
Thanks
I definately need help with this
Is it possible to only copy files that don't already exist in the destination?
Thanks
July 17, 2012 at 1:54 pm
SQLSACT (7/17/2012)
OTF (7/17/2012)
I would use a Powershell Script for this. Flexible and easy to change, if required.If you need help with it let us know.
Thanks
I definately need help with this
Is it possible to only copy files that don't already exist in the destination?
Thanks
That should be possible, yes.
July 17, 2012 at 4:01 pm
SQLSACT (7/17/2012)
Hi AllHow would I setup a script to copy files from a shared location on one server, to a shared location on another server?
The extension of the files would be .trn
I assume that I would need to use xp_cmdshell
Thanks
I just actually went through and set up CMDEXEC sql agent jobs to get rid of xp_cmdshell. as part of my effort to boost security any thing that uses xp_cmdshell has to be rewritten so i can eventually disable it on our servers. i found it opens a hole that does not need to exist any more.
For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]
Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
Jeff Moden's Cross tab and Pivots Part 1[/url]
Jeff Moden's Cross tab and Pivots Part 2[/url]
July 17, 2012 at 10:55 pm
capn.hector (7/17/2012)
i found it opens a hole that does not need to exist any more.
It only opens a hole if you're server security isn't setup correctly. xp_CmdShell isn't the problem.... bad security is.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply