简体   繁体   English

如何备份 Azure 表存储

[英]How to make backup of Azure table storage

I have a requirement where I need to migrate data from one azure table storage , basically from one table to other table (Both table could be either in same subscription or different subscription).我有一个需求,我需要将数据从一个 azure 表存储迁移,基本上是从一个表迁移到另一个表(两个表可以是相同的订阅或不同的订阅)。

Is there any way in Azure table storage to do above requirement like in SQL storage where user can generate scripts or backup of entire database or individual table.在 Azure 表存储中是否有任何方法可以像在 SQL 存储中那样满足上述要求,用户可以在其中生成脚本或备份整个数据库或单个表。

Short answer: there's no built-in backup.简短回答:没有内置备份。 Longer answer:更长的答案:

  • There's no built-in backup service for table storage, or "snapshot" feature (which blobs have): You'll need to do your own copy operation, from one table to another.没有用于表存储的内置备份服务或“快照”功能(blob 具有):您需要执行自己的复制操作,从一张表到另一张表。 There's a REST API available along with SDKs, PowerShell cmdlets, CLI commands, and AzCopy (all built upon the API).有一个 REST API 以及 SDK、PowerShell cmdlet、CLI 命令和 AzCopy(均基于 API 构建)。 There are also a bunch of 3rd-party tools you can search for.您还可以搜索许多 3rd 方工具。 How you accomplish your table-copying is up to you.如何完成表复制取决于您。

  • Table storage is durable storage - triple-replicated within a region (and optionally geo-replicated to another region).表存储是持久存储 - 在一个区域内进行三次复制(并且可以选择异地复制到另一个区域)。 Even if storage became unavailable in the primary region, you'd have the option of reading from the paired region (assuming you enabled your storage account to be geo-redundant).即使存储在主要区域中变得不可用,您也可以选择从配对区域读取(假设您已启用存储帐户为异地冗余)。 Note: This is not the same as backup - if you delete an entity in a table, that deletion is replicated everywhere注意:这与备份不同 - 如果您删除表中的实体,则该删除会复制到任何地方

  • Storage-copying (eg copying entities out of a table, to another table) will be the same, regardless of subscription.无论订阅如何,存储复制(例如,将实体从一个表复制到另一个表)都是相同的。 Storage accounts are keyed on account namespace + access key (and optionally SAS).存储帐户以帐户命名空间 + 访问密钥(以及可选的 SAS)为键。

I realize this is an old question, but I thought I'd leave this response for those who are still looking for ways to back up Azure table data in 2018.我意识到这是一个老问题,但我想我会把这个回答留给那些仍在寻找在 2018 年备份 Azure 表数据的方法的人。

I've seen a lot of suggestions for using AzCopy, which looks like a great way to do it.我已经看到很多关于使用 AzCopy 的建议,这看起来是一个很好的方法。

However, if using C# works better for you, I wrote a tool (that my workplace allowed me to open source) which is on github: https://github.com/Watts-Energy/Watts.Azure#azure-data-factory但是,如果使用 C# 更适合您,我在 github 上编写了一个工具(我的工作场所允许我开源): https : //github.com/Watts-Energy/Watts.Azure#azure-data-factory

The main objective of the project is not backups, but it can be used to do just that, and we have backups running in Azure Web Jobs using the functionality therein.该项目的主要目标不是备份,但它可以用来做到这一点,我们在 Azure Web 作业中使用其中的功能运行备份。 We open sourced it because we figured it could prove useful to others, besides us, since it allows you to do 'incremental' backups, which I don't know if you can accomplish with AzCopy.我们开源它是因为我们认为它可以证明对除我们之外的其他人有用,因为它允许您进行“增量”备份,我不知道您是否可以使用 AzCopy 完成。 I'm not saying you can't, only that I haven't a clue whether that's possible.我不是说你不能,只是我不知道这是否可能。

The idea is that you create a small console application (to be hosted as an Azure Web Job for example) in .NET and you can eg do something like this:这个想法是您在 .NET 中创建一个小型控制台应用程序(例如作为 Azure Web 作业托管),您可以执行以下操作:

DataCopyBuilder
.InDataFactoryEnvironment(environment)
.UsingDataFactorySetup(environment.DataFactorySetup)
.UsingDefaultCopySetup()
.WithTimeoutInMinutes(numberOfMinutes)
.AuthenticateUsing(authentication)
.CopyFromTable(sourceTable)
.WithSourceQuery(null)
.ToTable(targetTable)
.ReportProgressToConsole()
.StartCopy();

If you, when the job runs, store the time (in UTC) when you started your last copy operation, you can supply a 'source query' (example: ' Timestamp gt datetime'{lastBackupStarted.ToIso8601()} ') rather than null like in the example above, and it will only take data modified since that date.如果您在作业运行时存储上次复制操作开始时的时间(以 UTC 为单位),则可以提供“源查询”(例如:“ Timestamp gt datetime'{lastBackupStarted.ToIso8601()} ”)而不是null就像上面的例子一样,它只会从那个日期起修改数据。 It's explained in greater detail in the project README.txt .它在项目 README.txt 中有更详细的解释。

Again, not sure if it's useful to anyone, but it does solve some challenges we have had.同样,不确定它是否对任何人有用,但它确实解决了我们遇到的一些挑战。

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

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