BigQuery Restore Deleted Tables In 2 Easy Steps

on BigQuery Delete Table, ETL, Google BigQuery • March 17th, 2022 • Write for Hevo

Bigquery restore deleted tables FI

BigQuery is a completely managed Data Warehouse service offered by Google. It can store petabytes of data. BigQuery supports standard SQL dialect and provides JDBC and ODBC drivers for facilitating client connections. Like all modern Data Warehouse services, it separates compute and storage processes. It can also query data that is stored in object stores like Google Cloud Storage. In that sense, it can be thought of as an amalgamation of a Data Lake and Data Warehouse.

Beyond the standard Data Warehouse features, BigQuery provides many other nice-to-have features like native machine learning support, natural language-based querying, geospatial analysis support, multi-cloud support, etc. This post is about the automatic backup and restores feature of BigQuery and how to restore tables using it. 

In this article, you will learn how to BigQuery Restore Deleted Tables in 2 Easy Steps. You will also learn about BigQuery and its key features.

Table of Contents

What is BigQuery?

BigQuery by Google is a Data Warehousing solution that stands out. It takes advantage of the Google Cloud Platform to provide a fully managed server-less solution to users. Furthermore, its cloud-native nature provides a wide range of benefits for customers, including lightning-fast querying on a terabyte-scale in seconds. Another major advantage is the server-less design, which helps users save time and money. Simply said, you can scale up and down quickly without wasting resources.

Key Features of BigQuery

  • Integrations: Because Google BigQuery includes so many built-in integrations, creating a data lake is a breeze.
  • Built-in Machine Learning Integration: For machine learning models on huge datasets, extensive machine learning understanding was once required. Machine learning integration on Google BigQuery, on the other hand, removed this limitation because users could utilize the tool to create such a database.
  • Multi-Cloud Functionality: BigQuery’s multi-cloud functionality allows users to study and query data from several cloud platforms.
  • Automated Data Transfer: You can use this functionality to schedule data transfers into Google BigQuery regularly.

Simplify BigQuery’s ETL & Data Analysis with Hevo’s No-code Data Pipeline

Hevo Data, a No-code Data Pipeline, helps load data from any data source such as Databases, SaaS applications, Cloud Storage, SDK,s, and Streaming Services and simplifies the ETL process. It supports 100+ Data Sources (Including 40+ Free Sources). It is a 3-step process by just selecting the data source, providing valid credentials, and choosing the destination. 

Hevo loads the data onto the desired Data Warehouse/destination like BigQuery in real-time and enriches the data and transforms it into an analysis-ready form without having to write a single line of code. Its completely automated pipeline, fault-tolerant, and scalable architecture ensure that the data is handled in a secure, consistent manner with zero data loss and supports different forms of data. The solutions provided are consistent and work with different BI tools as well.

GET STARTED WITH HEVO FOR FREE

Check out why Hevo is the Best:

  • Secure: Hevo has a fault-tolerant architecture that ensures that the data is handled securely and consistently with zero data loss.
  • Schema Management: Hevo takes away the tedious task of schema management & automatically detects the schema of incoming data and maps it to the destination schema.
  • Minimal Learning: Hevo, with its simple and interactive UI, is extremely simple for new customers to work on and perform operations.
  • Hevo Is Built To Scale: As the number of sources and the volume of your data grows, Hevo scales horizontally, handling millions of records per minute with very little latency.
  • Incremental Data Load: Hevo allows the transfer of data that has been modified in real-time. This ensures efficient utilization of bandwidth on both ends.
  • Live Support: The Hevo team is available round the clock to extend exceptional support to its customers through chat, email, and support calls.
  • Live Monitoring: Hevo allows you to monitor the data flow and check where your data is at a particular point in time.

Simplify your Data Analysis with Hevo today! SIGN UP HERE FOR A 14-DAY FREE TRIAL!

Prerequisites

  • Google Cloud Account with BigQuery Storage API permission.
  • Basic understanding of database concepts.

BigQuery Restore Deleted Tables: Understanding BigQuery Backup And Restore Feature

Despite taking utmost care and establishing bulletproof processes, mistakes do happen in the world of data. This is why backing up and restoring features are critical for a modern data warehouse. BigQuery provides a feature called time travel that allows one to restore the table to any point of time in the last 7 days. This feature is a great help in case accidental modification of data happens. This is also a great feature when you want to analyze the state of the table at a particular point in time to troubleshoot bugs. Time travel is enabled by default for all tables and can be exploited using the console, via commands, or even through SQL.

For users who want historical data availability beyond 7 days, BigQuery provides a feature called snapshots. Snapshots are readable copies of data from a table a specific points in time. Snapshots need to be separately configured and scheduled. Saved snapshots can be restored to other tables to bring back data from history. The granularity of historic data restoration depends on the scheduled frequency of snapshots. Snapshots generally take lesser space than the original table since they only store the changes concerning the original table and not complete data. 

BigQuery Restore Deleted Tables Process: Backing Up and Restoring BigQuery Tables

We will now try to create snapshots for a BigQuery Restore Deleted Table from the snapshot. 

BigQuery Restore Deleted Tables Steps: Creating Snapshots

  • Step 1: The first step to BigQuery restore deleted table is to create a snapshot of any table is as easy as heading to the BigQuery Console and configuring the expiration time for the snapshot. Head to the BigQuery Console, click on the table that you are trying to backup and click Snapshot:
BigQuery Restore Deleted Tables: Create snapshot step 1
Image Source: Self
  • Step 2: The next step to BigQuery restore deleted table is to configure the details for the snapshot destination. Two key attributes need to be configured in this section. Expiration time and Snapshot time.

Expiration time represents the time after which the snapshot will be discarded. If no expiration time is specified, this will default to the source table’s expiration time. Snapshot time refers to the point in time in which your source table’s state should be copied. Because of BigQuery’s time travel function, this can be set at any time in the last 7 days. This means, you are not just limited to taking snapshots at the current time but can take a snapshot of your table state at any point in the last 7 days. 

BigQuery Restore Deleted Tables: Create snapshot step 2
Image Source: Self
  • Step 3: The next step to BigQuery restore deleted table is to Click Save and your snapshot should now be created in the dataset that you specified. 

Snapshots can be created using the cloud console, SQL, bq command or the APIs. For example, if you want to do this through SQL, you can use the below snippet.

CREATE SNAPSHOT TABLE
  myproject.backup.customers
  CLONE myproject.prod.customers
  OPTIONS(expiration_timestamp = TIMESTAMP "2022-05-27 12:00:00.00-00:00")

In production, snapshots are often scheduled to run in predefined times so that tables are backup up regularly. This can be done by creating Google Service Account bots.

BigQuery Restore Deleted Tables Steps: Restoring Tables from Snapshots

  • Step 1: The next step to BigQuery restore deleted table is to restore a table from a snapshot, head to the dataset where the snapshot was configured, and click on the specific snapshot that has to be restored. 
BigQuery Restore Deleted Tables: Restore tables step 1
Image Source: Self
  • Step 2: The next step to BigQuery restore deleted table is this. The resulting popup will ask for details of the destination project and the dataset in which the table has to be created. A key detail is a checkbox for allowing overwriting. If checked, this will ensure that the target table is overwritten if it already exists. Otherwise, an error will be thrown if the target table exists. 
BigQuery Restore Deleted Tables: Restore tables step 2
Image Source: Self

BigQuery restore deleted table can also be done through SQL, bq commands, or API. For example, to restore a table using SQL, the following SQL command can be used.

CREATE TABLE library.customers_new
CLONE library_backup.customers

That’s it. You have now learned how to create snapshots and restore BigQuery tables from snapshots. BigQuery’s time travel feature works even if the table is deleted till the 7 days window is expired. 

Conclusion

BigQuery restore deleted table has been explained in two easy steps in this article. BigQuery’s time travel feature, snapshots and restore mechanism protects users against accidental deletes and data corruption. While the console makes it easier for anyone to do it, in some cases like restoring a deleted table, one will have to use the SQL or ‘bq’ command method. On another note, if you are someone who works a lot with BigQuery and needs a way to make data transfers to and from BigQuery easier, you should checkout Hevo. 

However, as a Developer, extracting complex data from a diverse set of data sources like Databases, CRMs, Project management Tools, Streaming Services, Marketing Platforms to BigQuery can seem to be quite challenging. If you are from non-technical background or are new in the game of data warehouse and analytics, Hevo Data can help!

Visit our Website to Explore Hevo

Hevo Data will automate your data transfer process, hence allowing you to focus on other aspects of your business like Analytics, Customer Management, etc. This platform allows you to transfer data from 100+ multiple sources to Cloud-based Data Warehouses like Google BigQuery, Amazon Redshift, etc. It will provide you with a hassle-free experience and make your work life much easier.

Want to take Hevo for a spin? Sign Up for a 14-day free trial and experience the feature-rich Hevo suite first hand.

You can also have a look at our unbeatable pricing that will help you choose the right plan for your business needs!

No-Code Data Pipeline for BigQuery