简体   繁体   English

在 bigquery 中恢复已删除的数据集

[英]Restore deleted dataset in bigquery

we have deleted some dataset and now we want them(deleted before 24 hours).我们已经删除了一些数据集,现在我们想要它们(24 小时前删除)。 so i check the documentation and followed the steps,所以我检查文档并按照步骤操作,

1. reacreate dataset with same name
2. bq cp mydataset.mytable@ -3600000 mydataset.newtable

i also recreated table schema in db and then tried above.我还在数据库中重新创建了表模式,然后在上面尝试了。 but its giving me error that dataset is not present in my region.但它给我的错误是数据集不存在于我所在的地区。

I tried with select,我试过 select,

SELECT * FROM `mydataset.mytable`  FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 48 HOUR);

but no luck.但没有运气。 can anyone help here.任何人都可以在这里帮忙。 what am I missing?我错过了什么? is there any time bound for this restoration if we deleted dataset?如果我们删除数据集,此恢复是否有时间限制? (like for table we can go back 7 days) (喜欢桌子我们可以 go 退回 7 天)

Note: for deletion we followed below steps:注意:对于删除,我们遵循以下步骤:

  1. drop command to drop table drop命令删除表
  2. once all tables dropped then we deleted dataset一旦所有表都删除了,我们就删除了数据集

Deleting a dataset is permanent and cannot be undone. 删除数据集是永久性的,无法撤消。 After you delete a dataset, it cannot be recovered or restored . 删除数据集后,将无法恢复或恢复

BigQuery allows you to recover deleted tables . BigQuery 允许您恢复已删除的表 If you are within the dataset's Time Travel Window you can restore tables, see more at the next document .如果您在数据集的Time Travel Window内,您可以恢复表格,请参阅下一个文档了解更多信息。

You can restore the tables from deleted dataset after recreating it with the same name.在使用相同的名称重新创建数据集后,您可以从已删除的数据集中恢复表。 However, you have to know tables names.但是,您必须知道表名。

# 1) Delete the dataset
bq rm -r -f -d TEST_DATASET

# 2) Create a new dataset for restore
bq mk -d --location=us-east4 TEST_DATASET_RESTORED

# 3) Recreate the origin dataset with the same name
bq mk -d --location=us-east4 aw-sndbx-dataplatform-01:TEST_DATASET

# 4) Restore the table from the latest snapshot (alias @0)
bq cp TEST_DATASET.test_table@0 TEST_DATASET_RESTORED.test_table

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

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