Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

BigQuery restore dataset

Modita
New Member

Hi,

A dataset has been deleted by mistake. It contains several views and tables. Is there any way to retrieve them all

0 2 4,267
2 REPLIES 2

Unfortunately, once a dataset is deleted in BigQuery, it cannot be directly recovered in its entirety. However, you still have options to potentially retrieve tables and views individually:

For Tables:

  1. Time Travel: BigQuery's Time Travel feature is your first line of defense for table recovery. If the deletion occurred within the last 7 days, this feature allows you to access and query past versions of a table. For detailed steps, refer to the official documentation on restoring a table.

  2. Snapshots: If you created snapshots of your tables before their deletion, these can be a lifesaver. You can restore your tables from these snapshots, even beyond the 7-day window of the Time Travel feature. For more on this, see how to restore table snapshots.

  3. Backups: As a best practice, if you have backups of your dataset or individual tables, you can restore your data from these backups. Regular backups are crucial for mitigating data loss.

For Views:

  1. Query History: To recover views, use the BigQuery Logs Viewer to search for "CREATE VIEW" or "CREATE OR REPLACE VIEW" queries made before the deletion. This can help you find the necessary SQL queries to recreate your views in a new dataset.

  2. Code Repositories: If your views were scripted or noted in notebooks, check your version control systems or code repositories. You can re-run these scripts to recreate the views.

Important Notes:

  • Dataset Recreation Limitation: Be aware that you cannot recreate a deleted dataset with the same name for 24 hours following its deletion.
  • Knowledge of Names: You need to know the exact names of the tables and views you're trying to restore.
  • Metadata and Settings Loss: Remember, even if you successfully recover all tables and views, the original dataset's metadata and associated settings will be lost.

Additional Resources:

If a dataset is deleted in BigQuery, check the following:

  1. BigQuery Console:

    • Look in the "Deleted datasets" section for possible restoration.
  2. Audit Logs:

    • Check audit logs in Google Cloud Console for DELETE events on the dataset.
  3. Contact Support:

    • Reach out to Google Cloud Support for assistance.
  4. Snapshots or Backups:

    • Restore from any snapshots or backups you might have.
  5. Ask Administrators:

    • Check with other administrators for potential backups.

Act quickly, as recovery options may depend on retention policies and configurations. Implement regular backups to avoid future data loss.