Prune Branch History (Data Management)

Summary

Removes retired archive records from branch-versioned datasets.

Learn more about prune branch history

Usage

  • When no Prune Before Date parameter value is specified, the tool will prune as much of the archive history as possible based on referenced moments. When a Prune Before Date parameter value is specified, all rows will be removed up to that moment.

  • If the Prune Before Date parameter value is invalid due to a version or replica that is referencing a moment before the requested prune date, a warning message will be issued. The output log will report the earliest moment that can be used and will include the moment and version that blocked the tool.

    Learn more about referenced moments

  • The versioning type of the Input Dataset parameter value's geodatabase connection must be set to branch.

  • The dataset must be registered as branch versioned.

  • The tool can only be run by the data owner.

  • The Input Dataset parameter value can be a feature class, feature dataset, or table. When the input is a feature dataset, all feature classes in that dataset and related data outside of the feature dataset will be processed, excluding data in another feature dataset.

  • If a feature class is in a feature dataset, use the feature dataset as the input.

  • An exclusive schema lock is required to run the tool. Services referencing the input data will need to be stopped using ArcGIS Server Manager.

Parameters

LabelExplanationData Type
Input Dataset

The feature class, feature dataset, or table that will be pruned.

Table View; Feature Dataset
Output Log File

A log file that reports the feature classes and tables that were pruned or will be pruned. The output file will also list the replicas and versions that prevented using the requested prune-before date.

File
Report Only
(Optional)

Specifies whether the eligible archive records will be reported or pruned.

  • Checked—The number of eligible archive records will be reported to the log file; they will not be pruned. This is the default.
  • Unchecked—The eligible archive records will be pruned.
Boolean
Only Prune System Tables

Specifies whether only the eligible internal tables will be reported or pruned

  • Checked—Only the eligible internal tables of the extension datasets will be pruned or reported to the log file.
  • Unchecked—All eligible tables will be pruned or reported to the log file. This is the default.
Boolean
Prune Before Date
(Optional)

Archive records that are older than the specified date and time will be pruned. The date and time must be in UTC. If no date is provided, the oldest referenced moment in the database will be used.

Date

Derived Output

LabelExplanationData Type
Output Dataset

The updated dataset.

Table View; Feature Dataset

arcpy.management.PruneBranchHistory(in_dataset, out_log, {report_only}, system_tables_only, {prune_before_date})
NameExplanationData Type
in_dataset

The feature class, feature dataset, or table that will be pruned.

Table View; Feature Dataset
out_log

A log file that reports the feature classes and tables that were pruned or will be pruned. The output file will also list the replicas and versions that prevented using the requested prune-before date.

File
report_only
(Optional)

Specifies whether the eligible archive records will be reported or pruned.

  • REPORT_ONLYThe eligible archive records will be reported to the log file; they will not be pruned. This is the default.
  • PRUNEThe eligible archive records will be pruned.
Boolean
system_tables_only

Specifies whether only the eligible internal tables will be reported or pruned.

  • SYSTEM_ONLYOnly the eligible internal tables of the extension datasets will be pruned or reported to the log file.
  • ALLAll eligible tables will be pruned or reported to the log file. This is the default.
Boolean
prune_before_date
(Optional)

Archive records that are older than the specified date and time will be pruned. The date and time must be in UTC. If no date is provided, the oldest referenced moment in the database will be used.

Date

Derived Output

NameExplanationData Type
out_dataset

The updated dataset.

Table View; Feature Dataset

Code sample

PruneBranchHistory example (Python window)

Prune the archive records of a class older than a specific date and time.

import arcpy
arcpy.management.PruneBranchHistory(
    in_dataset="feature_class",
    out_log=r"C:Projects\prune_data\testing",
    trim_before_date="1/15/2025 10:46:25 AM",
    report_only=False,
    system_tables_only="SYSTEM_ONLY"
)

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: No
  • Standard: Yes
  • Advanced: Yes

Related topics