Sql Server备份和移动备份文件:如何处理文件权限?

发布于 2024-08-25 11:42:04 字数 535 浏览 3 评论 0原文

通过我们的产品,我们为 SQL Server 数据库提供了一个简单的备份工具。该工具应该只需对任何文件夹进行完整备份和恢复。

当然,用户(通常是管理员)需要写入目标文件夹的权限。

为了避免无法执行到网络驱动器的备份的问题,我将备份写入到 Sql Server 备份目录中的临时文件中。然后我将其移动到目标文件夹。这需要从 SQL Server 备份文件夹中删除临时文件的权限。另一个方向的恢复也是一样的。

这似乎工作得很好,直到有人在 Vista 上测试它,默认情况下用户没有备份文件夹的写入权限

因此有很多解决方案可以解决这个问题,但似乎没有一个是真正好的。

一种解决方案是为临时文件找到另一个文件夹。执行备份的sql server 用户和管理员都需要读写权限。有这样的目录吗?

还有其他想法吗?多谢。


编辑:解决方案必须适用于 Sql Server 2005 和 2008、C# 3.0 (Smo)、Windows XP 和 Vista。

With our product we have a simple backup tool for the sql server database. This tool should just make a full backup and restore to and from any folder.

Of course, the user (usually an administrator) needs permission to write to the target folder.

To avoid the problem of not being able to perform a backup to a network drive, I write the backup to a temp file in the Sql Server backup directory. Then I move it to the target folder. This requires permission to delete the temporary file from the sql servers backup folder. Restore is the same in the other direction.

This seemed to work fine until someone tested it on vista, where the user does not have write access to the backup folder by default.

So there are many solutions to solve this, but none of them seemed to be really nice.

One solution would be to find another folder for the temporary file. Both the sql server user as well as the administrator performing the backup need read and write permissions. Is there such a directory?

Any other ideas? Thanks a lot.


Edit: Solution must work with Sql Server 2005 and 2008, C# 3.0 (Smo), Windows XP and Vista.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与之呼应 2024-09-01 11:42:04

执行备份操作的应用程序可以请求以备份模式打开文件。这意味着应用程序具有 SeBackupPrivilege 权限并且它打开设置了 FILE_FLAG_BACKUP_SEMANTICS 标志的文件:

SeBackupPrivilege—允许文件内容
检索,即使安全
文件上的描述符可能不会授予
这样的访问。来电者与
启用 SeBackupPrivilege 可以避免
需要任何基于 ACL 的安全检查。

虽然这听起来技术性且复杂,但实际上归结为使用 ROBOCOPY /B 复制文件

Applications performing backup operations can request to open files in the backup mode. What that means is that the application has the SeBackupPrivilege privilege and it opens files with the FILE_FLAG_BACKUP_SEMANTICS flag set:

SeBackupPrivilege—allows file content
retrieval, even if the security
descriptor on the file might not grant
such access. A caller with
SeBackupPrivilege enabled obviates the
need for any ACL-based security check.

While this sounds technical and complicated, what it boils down to in practice is to copy the files using ROBOCOPY /B

时光与爱终年不遇 2024-09-01 11:42:04

好的,我找到了解决方案。如果您比我更了解 Vista,那么实际上很简单。

备份文件夹的配置方式与 XP 下相同,但只有在进程处于提升模式下时,管理员权限才可用。为此,我只需向需要管理员权限的可执行文件添加一个清单:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

现在,我在调用应用程序时获得 UAC,并且一切正常。

Ok, I found the solution. It is actually pretty simple if you know a bit more about Vista then I do.

The backup folder is configured the same way as under XP, but the administrator permissions are not available until the process is in elevated mode. To get there, I just needed to add a manifest to the executable which requires the administrator privileges:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Now I get an UAC when calling the application and everything works fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文