简体   繁体   English

Sql Server以编程方式从远程客户端恢复/备份数据库

[英]Sql Server restore/backup database from remote client programmatically

I want to backup and restore my database that is in the server from my client Desktop application in C#. 我想从C#中的客户端桌面应用程序备份和恢复服务器中的数据库。 I already found some sample code that do backup/restore programmatically, however it backups on the server computer and restores just from the server computer. 我已经找到了一些以编程方式进行备份/恢复的示例代码,但是它在服务器计算机上进行备份并仅从服务器计算机进行恢复。 The users should be able to select the backup files from client by the client application or create backup files in the client computers. 用户应该能够通过客户端应用程序从客户端选择备份文件,或者在客户端计算机中创建备份文件。

How can I do backup/restore remotely? 如何远程备份/恢复?

I found a very useful method to backup remotely: http://www.codeproject.com/Articles/33963/Transferring-backup-files-from-a-remote-SQL-Server . 我找到了一种非常有用的远程备份方法: http//www.codeproject.com/Articles/33963/Transferring-backup-files-from-a-remote-SQL-Server However, the problem still exist for restoring remotely. 但是,远程恢复仍然存在问题。

Make a share on the server . 服务器上进行共享。 Then, copy backups there from the client machine, if you want to restore database, or copy backups to the client machine from there, if you want to store backup at the client. 然后,如果要在客户端上存储备份,则从客户端计算机复制备份,如果要还原数据库,或从那里将备份复制到客户端计算机。
Of course, client must have r/w permissions for this share. 当然,客户端必须具有此共享的r / w权限。

Just an idea. 只是一个想法。

While Taking backup, Just store the backup file name and location in database table. 进行备份时,只需将备份文件名和位置存储在数据库表中即可。 So that you can show it to the user for recovery. 这样您就可以将其显示给用户进行恢复。

Still you can use database code restore with dynamic backup location argument. 您仍然可以使用动态备份位置参数进行数据库代码还原。

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

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