简体   繁体   English

通过使用窗口计划来安排SQL Server Express的每日备份

[英]schedule a daily backup with SQL Server Express by using window schedule

i want to schedule a daily backup with SQL Server Express by using window schedule. 我想使用窗口计划来计划SQL Server Express的每日备份。 I am able to backup my database to D drive.But when i try to backup my database to c drive. 我可以将数据库备份到D驱动器。但是,当我尝试将数据库备份到C驱动器时。 The ms sql return me this error MS SQL返回此错误

    Msg 3201, Level 16, State 1, Line 3
Cannot open backup device 'C:\inetpub\Project backup Live\LewreDB backup\Wednesday\20120502.bak'. Operating system error 5(failed to retrieve text for this error. Reason: 15105).
Msg 3013, Level 16, State 1, Line 3
BACKUP DATABASE is terminating abnormally.

Here is my query 这是我的查询

   DECLARE @pathName NVARCHAR(512) 
SET @pathName = 'C:\inetpub\Project backup Live\LewreDB backup\' + DATENAME(DW,GETDATE())+'\'+ Convert(varchar(8), GETDATE(), 112) + '.bak' 
BACKUP DATABASE [LEWREDB] TO  DISK = @pathName WITH NOFORMAT, NOINIT,  NAME = N'db_backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10

Did any one face this problem before 有人遇到过这个问题吗

Are you trying to backup a SQL Server Express database on a remote server to your local C: drive? 您是否正在尝试将远程服务器上的SQL Server Express数据库备份到本地C:驱动器?

I got a similar error when I thought I could execute SQL on a remote database to backup to a location on my C:\\ drive. 当我以为可以在远程数据库上执行SQL以备份到C:\\驱动器上的某个位置时,遇到了类似的错误。

In any case I can recommend a workaround where you run the backup in a batch file fired by a windows scheduled task and include a line in the batch file to copy the backup from the D: drive location on the SQL Express Server to your C: drive location wherever that may be. 无论如何,我都建议一种解决方法,在Windows计划任务触发的批处理文件中运行备份,并在批处理文件中包含一行,以将备份从SQL Express Server上的D:驱动器位置复制到C:不论可能在哪里,都应驱动器定位。

This generally happens if you are using the Windows. 如果使用Windows,通常会发生这种情况。 Always run the application using Adminisatrator privileges and check if you can modify delete or create the folder in c: drive manually. 始终使用Adminisatrator特权运行该应用程序,并检查是否可以手动在c:驱动器中修改删除或创建文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM