<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Backing up your unity catalog metadata in Data Governance</title>
    <link>https://community.databricks.com/t5/data-governance/backing-up-your-unity-catalog-metadata/m-p/118544#M2476</link>
    <description>&lt;P&gt;Unity Catalog (UC) tracks the metadata and your cloud storage accounts store the your data. This python script will extract the metadata from {catalog}.information_schema into folders in a storage location. Take this and put into a notebook.&amp;nbsp; Make data backups from the cloud storage console. {catalog} can also include system, which will cover every catalog in UC. The UC configuration is recoverable from the information_schema metadata however I've not had time to make the recovery run in parallel and perform to reasonable expectations.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;%python&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;storage_location = dbutils.widgets.get("storageLocation")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;catalog_name = dbutils.widgets.get("catalogName")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;(storage_location, catalog_name)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;%python&lt;/FONT&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;#&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;# For every table in information schema, make a backup copy of it to the storage location and all of the other metadata&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;#&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;table_list = spark.catalog.listTables(f"`{catalog_name}`.information_schema")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;for table in table_list:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt;print(f'backing up {table.catalog}.information_schema.{table.name} to {storage_location}/{table.name}...')&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt; info_schema_table_df = spark.sql(f"SELECT * FROM {table.catalog}.information_schema.{table.name}")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt; info_schema_table_df.write.format("delta").mode("overwrite").save(f"{storage_location}/{table.name}")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt;print('backup complete')&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Thu, 08 May 2025 15:13:58 GMT</pubDate>
    <dc:creator>DouglasMoore</dc:creator>
    <dc:date>2025-05-08T15:13:58Z</dc:date>
    <item>
      <title>Backing up your unity catalog metadata</title>
      <link>https://community.databricks.com/t5/data-governance/backing-up-your-unity-catalog-metadata/m-p/118544#M2476</link>
      <description>&lt;P&gt;Unity Catalog (UC) tracks the metadata and your cloud storage accounts store the your data. This python script will extract the metadata from {catalog}.information_schema into folders in a storage location. Take this and put into a notebook.&amp;nbsp; Make data backups from the cloud storage console. {catalog} can also include system, which will cover every catalog in UC. The UC configuration is recoverable from the information_schema metadata however I've not had time to make the recovery run in parallel and perform to reasonable expectations.&lt;BR /&gt;&lt;BR /&gt;&lt;FONT face="andale mono,times"&gt;%python&lt;/FONT&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;storage_location = dbutils.widgets.get("storageLocation")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;catalog_name = dbutils.widgets.get("catalogName")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;(storage_location, catalog_name)&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;%python&lt;/FONT&gt;&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;#&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;# For every table in information schema, make a backup copy of it to the storage location and all of the other metadata&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;#&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;table_list = spark.catalog.listTables(f"`{catalog_name}`.information_schema")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT face="andale mono,times"&gt;for table in table_list:&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt;print(f'backing up {table.catalog}.information_schema.{table.name} to {storage_location}/{table.name}...')&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt; info_schema_table_df = spark.sql(f"SELECT * FROM {table.catalog}.information_schema.{table.name}")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt; info_schema_table_df.write.format("delta").mode("overwrite").save(f"{storage_location}/{table.name}")&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="andale mono,times"&gt;print('backup complete')&lt;/FONT&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 08 May 2025 15:13:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-governance/backing-up-your-unity-catalog-metadata/m-p/118544#M2476</guid>
      <dc:creator>DouglasMoore</dc:creator>
      <dc:date>2025-05-08T15:13:58Z</dc:date>
    </item>
  </channel>
</rss>

