简体   繁体   English

数据库备份

[英]Database Backup

Scenario 情境

i want to take backup from 7 client database to 1 server database. 我想从7个客户端数据库备份到1个服务器数据库。 i dont know structure of the db { either server or client db }. 我不知道db {服务器或客户端db}的结构。 both databases are having old data. 这两个数据库都有旧数据。 now i have to make the tool take the backup for that. 现在,我必须使该工具为此备份。 and should possible to backup old data also[if any updates done on old data.] please help to find the solution for this. 并且也应该备份旧数据[如果对旧数据进行了任何更新。]请帮助找到解决方案。 1. how can i proceed with the problem. 1.我该如何解决这个问题。 2. database not specified, may be MS access or Sql server 2005 3. In which i can implement this [ I am thinking of doing it in c#] 2.未指定数据库,可能是MS Access或Sql Server2005。3.我可以在其中实现此目标[我正在考虑在c#中完成]

please help me to find the solution 请帮助我找到解决方案

I'm not sure why you would want to go about it this way - if you are merely trying to copy the client databases (which I interpret as being "file based") then why not simply take copies of their files as part of the wider backup strategy? 我不确定您为什么要这样处理-如果您只是尝试复制客户端数据库(我认为这是“基于文件”),那么为什么不简单地将其文件副本作为文件的一部分呢?更广泛的备份策略?

If you to write the backup stuff to place all the data in a server based RDBMS, then you are also going to have to think about how you restore that information later on - which presumably means even more coding for you. 如果您编写备份内容以将所有数据放置在基于服务器的RDBMS中,那么以后您还必须考虑如何还原该信息-可能意味着需要更多的编码。

So - I don't think this is a good idea, but if you are determined, I would start off by writing a class (which will be almost abstract) dedicated to the purpose of reading the structure of the client database (tables, fields, views etc). 所以-我认为这不是一个好主意,但是如果您下定决心,我将首先编写一个类(几乎是抽象的),专门用于读取客户端数据库的结构(表,字段) ,观看次数等)。 I'd then inherit from that to get a specific class for doing this for each individual type of client DB. 然后,我将从中继承来获得一个特定的类,以针对每种单独类型的客户端数据库执行此操作。 Once you have that, you can use ADO.Net to read values from the tables in the Client DB, populate datatables with the information, and then write that information back out to the Server based DB. 一旦有了这些,就可以使用ADO.Net从Client DB中的表中读取值,用信息填充数据表,然后将该信息写回到基于Server的DB中。

I really can't stress enough though that I don't like this idea - it seems overly complicated, and also won't deal with functions etc. 尽管我不喜欢这个主意,但我真的不能足够强调-它似乎过于复杂,也不会处理函数等。

Good luck anyway, 反正祝你好运

Martin 马丁

Advisability of doing this aside, one simple answer for a particular subset of the problem would be to create a DSN for a target SQL Server (or any server database) and in Access export table by table to the DSN. 除了这样做,建议为该问题的特定子集提供一个简单的答案,即为目标SQL Server(或任何服务器数据库)创建DSN,并在Access中逐表导出到DSN。 You can do this through the Access UI and it can be automated within Access with DoCmd.TransferDatabase. 您可以通过Access UI来执行此操作,并且可以在Access中使用DoCmd.TransferDatabase将其自动化。 It can be a little fiddly figuring out the proper connect string, and you'd also need to do something about renaming the exported tables so there are no collisions between databases, but that can be handled quite easily in a bit of VBA code. 弄清楚正确的连接字符串可能有点麻烦,并且您还需要对重命名导出的表进行一些操作,以使数据库之间没有冲突,但是可以通过一些VBA代码轻松地解决。

I post this only because many people overlook the Access capability to export to an ODBC DSN, which requires no writing of DDL and so forth. 我之所以发表这篇文章,仅是因为许多人忽略了导出到ODBC DSN的访问功能,该功能不需要编写DDL等。 It may or may not make correct choices about target data types, though, so you'd have to see in any particular situation if it's good enough or not. 但是,它可能会或可能不会对目标数据类型做出正确的选择,因此您必须在任何特定情况下查看它是否足够好。

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

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