Skip to content

Commit 895a5c0

Browse files
committed
Add Jupyter notebook for restoring datasets and tables in BigQuery
1 parent d2052a1 commit 895a5c0

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

workspace/restore_data.ipynb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "071bb978",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"## [Restore deleted dataset](https://docs.cloud.google.com/bigquery/docs/restore-deleted-datasets#restore_a_dataset)\n",
11+
"UNDROP SCHEMA httparchive.crawl;"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"id": "1f18b3e6",
17+
"metadata": {},
18+
"source": [
19+
"## [Restore deleted table](https://docs.cloud.google.com/bigquery/docs/restore-deleted-tables#restore_a_table)\n",
20+
"!date -d '2025-08-04 16:00:00.000000Z' +%s000"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"id": "fe7ae694",
27+
"metadata": {},
28+
"outputs": [],
29+
"source": [
30+
"!bq cp httparchive.crawl.pages@1759670400000 httparchive.crawl_staging.pages_backup_20250804"
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"id": "7edfdae5",
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"## [Restore a table to a specific point in time](https://cloud.google.com/bigquery/docs/restore-tables#restoring_a_table_to_a_specific_point_in_time)\n",
41+
"SELECT *\n",
42+
"FROM httparchive.crawl.pages\n",
43+
" FOR SYSTEM_TIME AS OF TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 1 HOUR);"
44+
]
45+
}
46+
],
47+
"metadata": {
48+
"kernelspec": {
49+
"display_name": "Python 3",
50+
"language": "python",
51+
"name": "python3"
52+
},
53+
"language_info": {
54+
"name": "python",
55+
"version": "3.12.8"
56+
}
57+
},
58+
"nbformat": 4,
59+
"nbformat_minor": 5
60+
}

0 commit comments

Comments
 (0)