<?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 Re: How to preserve my database when the cluster is terminated? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13521#M8194</link>
    <description>&lt;P&gt;ok how about this: download your files from dbfs to your computer:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/66685638/databricks-download-a-dbfs-filestore-file-to-my-local-machine" target="test_blank"&gt;https://stackoverflow.com/questions/66685638/databricks-download-a-dbfs-filestore-file-to-my-local-machine&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not ideal but at least you do not lose your data.  When you want to work further on the downloaded files you can upload them again using the UI.&lt;/P&gt;&lt;P&gt;When finished download etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create a table on the files (which is very easy) and you are good to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 08:54:05 GMT</pubDate>
    <dc:creator>-werners-</dc:creator>
    <dc:date>2023-05-03T08:54:05Z</dc:date>
    <item>
      <title>How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13514#M8187</link>
      <description>&lt;P&gt;Whenever my cluster is terminated, I lose my whole database(I'm not sure if it's related, I made those database with delta format. ) And since the cluster is terminated in 2 hours from not using it, I wake up with no database every morning.&lt;/P&gt;&lt;P&gt;I don't want to run code every morning to make whole database again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way that I can preserve my database?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to clone cluster, but it didn't make my database back again. Also, I tried to restart the cluster, but it wasn't able to restart it. &lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 00:58:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13514#M8187</guid>
      <dc:creator>daindana</dc:creator>
      <dc:date>2021-10-14T00:58:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13515#M8188</link>
      <description>&lt;P&gt;Please check where on dbfs database/tables are created. Please check file system is files still there.&lt;/P&gt;&lt;P&gt;Sharing some code regarding creating database and tables could be useful. &lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 07:58:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13515#M8188</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2021-10-14T07:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13516#M8189</link>
      <description>&lt;P&gt;Hello, HubertDudek!&lt;/P&gt;&lt;P&gt;Thank you for help and advices!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is where I think that my database/tables are located:&lt;/P&gt;&lt;P&gt;dbfs:/user/hive/warehouse/db_name.db/table_name/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code that I use to create database:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;%sql
CREATE DATABASE IF NOT EXISTS database_name;
USE database_name;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this is the code that I use to create table:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;(df.write
        .format('delta')
        .mode('overwrite')
        .saveAsTable(table_name))&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 08:27:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13516#M8189</guid>
      <dc:creator>daindana</dc:creator>
      <dc:date>2021-10-14T08:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13517#M8190</link>
      <description>&lt;P&gt;do you happen to use the Community Edition? As apparently there are limitiations concerning own databases.&lt;/P&gt;&lt;P&gt;(https://community.databricks.com/s/feed/0D53f00001HKI7ACAX)&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 12:28:03 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13517#M8190</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2021-10-14T12:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13518#M8191</link>
      <description>&lt;P&gt;Ahhh yes! I am using community edition! Now I figured that was the reason why! Thank you for helping me&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 12:32:23 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13518#M8191</guid>
      <dc:creator>daindana</dc:creator>
      <dc:date>2021-10-14T12:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13519#M8192</link>
      <description>&lt;P&gt;So how to work around this? I am a student working on an assignment and I need to finish it, but two hours is not enough time!&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 15:57:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13519#M8192</guid>
      <dc:creator>Doris</dc:creator>
      <dc:date>2023-05-02T15:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13520#M8193</link>
      <description>&lt;P&gt;Once if the culstur gets terminated info will be lost &lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 18:07:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13520#M8193</guid>
      <dc:creator>Priyag1</dc:creator>
      <dc:date>2023-05-02T18:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13521#M8194</link>
      <description>&lt;P&gt;ok how about this: download your files from dbfs to your computer:&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/66685638/databricks-download-a-dbfs-filestore-file-to-my-local-machine" target="test_blank"&gt;https://stackoverflow.com/questions/66685638/databricks-download-a-dbfs-filestore-file-to-my-local-machine&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is not ideal but at least you do not lose your data.  When you want to work further on the downloaded files you can upload them again using the UI.&lt;/P&gt;&lt;P&gt;When finished download etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create a table on the files (which is very easy) and you are good to go.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 08:54:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/13521#M8194</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2023-05-03T08:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to preserve my database when the cluster is terminated?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/71516#M34335</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As the file still in the dbfs you can just recreate the reference of your tables and continue the work, with something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;db_name = "mydb"
from pathlib import Path
path_db = f"dbfs:/user/hive/warehouse/{db_name}.db/"
tables_dirs = dbutils.fs.ls(path_db)
for d in tables_dirs:
  table_name = Path(d.path).name  
  spark.sql(f"""CREATE TABLE IF NOT EXISTS {table_name}
            LOCATION '{d.path}'
            """)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2024 18:25:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-preserve-my-database-when-the-cluster-is-terminated/m-p/71516#M34335</guid>
      <dc:creator>dhpaulino</dc:creator>
      <dc:date>2024-06-03T18:25:19Z</dc:date>
    </item>
  </channel>
</rss>

