Using XCOPY to backup db files

Last Post 07 Nov 2011 06:17 AM by dbandee. 3 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
Wei
New Member
New Member

--
06 Dec 2010 04:52 PM
Hello,

I’m trying to backup database files (resided in the C: drive in ‘Program Files’ area) from the Microsoft SQL 2008 ‘data’ folder to a backup folder in the D: drive - using ‘xcopy’ (in a batch command file) but encountered “sharing violation” message (reported in command prompt windows).

The backup files in the D: drive will be backup to an external hard drive for safe keeping (as one backup strategy).

I’m running Windows server 2008R.

I have administrative rights. What is coursing this sharing violation and how can fix this issue?

Any help would be appreciated.

Wei
rm
New Member
New Member

--
07 Dec 2010 03:51 AM
You have to stop sql to do that, why don't backup db with sql statement instead?
gunneyk
New Member
New Member

--
07 Dec 2010 05:05 AM
rm is 100% correct. You really should use the BACKUP command or a 3rd party backup utility to do this. And if you use backup compression it will be faster and smaller as well.
dbandee
New Member
New Member

--
07 Nov 2011 06:17 AM
look into redgate or netbackup
but i agree with two previous posts, basically you cant copy file while in use by sql server. your best bet is create bak file and then xcopy it to D
I think you can also backup to another server using unc path. (it worked flawlessly in sql 2000 i never tried it in later versions).


Acceptable Use Policy
---