How Can I Undelete a Bigquery Dataset

How to recover IF you by mistake DELETE a whole BIGQUERY DATASET


    


A quick note on a selected feature of bigquery that I failed to see anyplace within the documentation. If you by mistake delete one table, you'll use a feature referred to as timetravel to revive the state of that table from a earlier in time. Follow the below instruction:


bq cp my_data_set.my_deleted_table@1234567890 my_data_set.my_restored_table

If you've got deleted the whole dataset but, the above code failed to restore. Then, just recreate a dataset with identical name the one that was deleted, timetravel on the tables that lived therein dataset can work once more. In alternative words, if you had accidentally deleted the dataset referred to as “my_data_set” merely recreate it first:

bq mk my_data_set

and then perform the previous timetravel operation for each table that was in your deleted dataset:


bq cp my_data_set.my_deleted_table@1234567890 my_data_set.my_restored_table

and then you can see all are back & to be ready to use it. One issue to notice is that if the dataset in question had a awfully sizable amount of tables, there is no any such a tools for that to get all the table list from bigquery information thus you need to prepare a list of table exist in your database. 

Bigquery’s bq command has the subsequent syntactical sugar to denote the oldest snapshot of a table:


bq cp my_data_set.my_deleted_table@0 my_data_set.my_restored_table

The zero timestamp references the earliest out there shot for that table. once managing a table that was deleted, however, no equivalent syntactical sugar exists to reference the most recent out there shot for that table.


For your reference :

[1] https://cloud.google.com/bigquery/docs/managing-datasets#deleting_a_dataset
[2] https://cloud.google.com/bigquery/docs/managing-tables#undeletetable

Post a Comment

0 Comments

Youtube Channel Image
TechAdvice Subscribe To watch more Blogging Tutorials
Subscribe