简体   繁体   中英

Restore deleted dataset in bigquery

we have deleted some dataset and now we want them(deleted before 24 hours). 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 * 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)

Note: for deletion we followed below steps:

  1. drop command to drop table
  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 . If you are within the dataset's Time Travel Window you can restore tables, see more at the next document .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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