<?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 Lakehouse backup table in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4306081#M6505</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data pipeline that loads data into a staging table with the destination setting set to "Overwrite." This seems to create a _backup_XXXXXXXXXX table each time I load data. Prior to using "Overwrite," I had it set to "Overwrite Schema," which did not create backup tables. However, this setting introduced datatype issues on the table, so I switched to "Overwrite."&lt;/P&gt;&lt;P&gt;Do you have any advice on how to prevent these backup tables from being created, or should I create a process to delete them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
    <pubDate>Thu, 28 Nov 2024 11:10:40 GMT</pubDate>
    <dc:creator>Soobramoney</dc:creator>
    <dc:date>2024-11-28T11:10:40Z</dc:date>
    <item>
      <title>Lakehouse backup table</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4306081#M6505</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data pipeline that loads data into a staging table with the destination setting set to "Overwrite." This seems to create a _backup_XXXXXXXXXX table each time I load data. Prior to using "Overwrite," I had it set to "Overwrite Schema," which did not create backup tables. However, this setting introduced datatype issues on the table, so I switched to "Overwrite."&lt;/P&gt;&lt;P&gt;Do you have any advice on how to prevent these backup tables from being created, or should I create a process to delete them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Thu, 28 Nov 2024 11:10:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4306081#M6505</guid>
      <dc:creator>Soobramoney</dc:creator>
      <dc:date>2024-11-28T11:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Lakehouse backup table</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4306793#M6507</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="787733" data-lia-user-login="Soobramoney" class="lia-mention lia-mention-user"&gt;Soobramoney&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to the official documentation, you can copy previous Version tables from Lakehouse by specifying version in the copy activity source. Then, I suggest you consider custom code in the pipeline to remove these tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A title="https://learn.microsoft.com/en-us/fabric/data-factory/connector-lakehouse-copy-activity#destination" href="https://learn.microsoft.com/en-us/fabric/data-factory/connector-lakehouse-copy-activity#destination" target="_blank" rel="noreferrer noopener"&gt;https://learn.microsoft.com/en-us/fabric/data-factory/connector-lakehouse-copy-activity#destination&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Specific steps you can consider:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, get a list of all the tables that need to be deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Write a script to delete these tables. You can write code in a language you are familiar with, here is an example using Python:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import pyodbc

# Connect to database
conn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=your_server;DATABASE=your_database;UID=your_username;PWD=your_password')
cursor = conn.cursor()

# Gets a list of tables to delete
tables_to_delete = ["backup_table1", "backup_table2", "backup_table3"]

# Delete list
for table in tables_to_delete:
    cursor.execute(f"DROP TABLE IF EXISTS {table}")
    print(f"Deleted table: {table}")

conn.commit()
cursor.close()
conn.close()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Integrate this script into your data pipeline. You can run this script after the data is loaded to ensure that the backup table is deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope you found this idea helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Nono Chen&lt;/P&gt;
&lt;P&gt;If this &lt;STRONG&gt;&lt;EM&gt;post&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;helps, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2024 02:33:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4306793#M6507</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-29T02:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Lakehouse backup table</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4375167#M6922</link>
      <description>&lt;P&gt;It seems you cannot prevent the backup tables when you are using the Overwrite setting. I had to create a clean job that runs once a day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("BackupTableCleanup")

backup_tables = spark.sql("SHOW TABLES")


drop_backup_tables = backup_tables.filter(
(backup_tables["tableName"].like('%_backup_%')) &amp;amp;
)


drop_statements = drop_backup_tables.rdd.map(lambda row: f"DROP TABLE {row['tableName']};").collect()

for statement in drop_statements:
try:
logger.info(f"Executing: {statement}")
print(f"Executing: {statement}")
spark.sql(statement)

logger.info(f"Successfully executed: {statement}")
except Exception as e:
logger.error(f"Failed to execute: {statement}. Error: {e}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 07:56:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/4375167#M6922</guid>
      <dc:creator>Soobramoney</dc:creator>
      <dc:date>2025-01-22T07:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Lakehouse backup table</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/5295255#M9583</link>
      <description>&lt;P&gt;I know this post is over a year old, but is this really an acceptable solution? Seems more like "Defect support system" (meaning we have to add extra coding and stuff to 'fix' stuff that Microsoft won't address.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jul 2026 21:59:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/Lakehouse-backup-table/m-p/5295255#M9583</guid>
      <dc:creator>ToddChitt</dc:creator>
      <dc:date>2026-07-14T21:59:06Z</dc:date>
    </item>
  </channel>
</rss>

