PrunePlan::from_prune_options()
Creates a prune plan from the given options.Parameters
repo: The repository to analyzeopts: Prune options
Returns
Returns aPrunePlan describing what will be deleted and repacked.
Errors
- If
repack_uncompressedis set and the repository is version 1 - If
keep_packorkeep_deletedurations are invalid
prune_repository()
Executes a prune plan on the repository.Errors
- If the repository is in append-only mode
- If pack operations fail
PruneOptions
Configuration options for the prune operation.Maximum data to repack as percentage of repo size, absolute size (e.g., ‘5b’, ‘2 kB’, ‘3M’, ‘4TiB’), or ‘unlimited’.
Tolerate limit of unused data as percentage of repo size after pruning, absolute size, or ‘unlimited’.
Minimum duration (e.g., 90d) to keep packs before repacking or removing. More recently created packs won’t be processed.
Minimum duration (e.g., 10m) to keep packs marked for deletion. More recently marked packs won’t be deleted.
Delete files immediately instead of marking them. Also removes all files already marked for deletion.
Delete index files early if
instant_delete is chosen. Allows prune to run when space is limited.Simply copy blobs when repacking instead of decrypting, possibly compressing, and encrypting.
Repack packs containing uncompressed blobs. Cannot be used with
fast_repack. Implies max_unused=0.Repack all packs. Implies
max_unused=0.Only repack packs which are cacheable. Default: true for hot/cold repository, else false.
Do not repack packs which only need to be resized.
Ignore these snapshots when looking for data still in use.
LimitOption
Specifies a size limit for prune operations.Variants
Size(ByteSize)
Absolute size limit (e.g., “10 GB”, “500 MiB”).
Percentage(u64)
Percentage of repository size (e.g., “10%” means 10% of total repo size).
Unlimited
No limit.
PrunePlan
A plan describing what should be repacked or removed.Methods
repack_packs()
Get the list of packs to repack.PruneStats
Statistics about a prune plan.Statistics about pack count to delete/keep/recover.
Statistics about pack sizes to delete/keep/recover.
Statistics about current pack situation.
Statistics about blobs in the repository.
Statistics about total sizes of blobs.
Number of unreferenced pack files.
Total size of unreferenced pack files.
Number of index files.
Number of index files to be rebuilt.
PackStats
Statistics about packs.Number of fully used packs.
Number of partly used packs.
Number of unused packs (equals packs-to-remove).
Number of packs to repack.
Number of packs to keep.
SizeStats
Statistics about sizes.Number of used blobs/bytes.
Number of unused blobs/bytes.
Number of blobs/bytes to remove.
Number of blobs/bytes to repack.
Number of blobs/bytes to remove after repacking.
Methods
Example
Advanced Usage
Repack Uncompressed Data
Instant Delete (Careful!)
Fast Repack
Notes
- Prune is a two-step process: mark for deletion, then delete after
keep_deleteduration - Use
instant_deletecarefully - only when no other processes access the repository - Repacking consolidates partly-used packs to reclaim space
max_repacklimits how much data is repacked to avoid long-running operationsmax_unusedensures unused data stays below a threshold- Recently created packs (within
keep_packduration) are never repacked - Prune automatically rebuilds index files as needed
- Append-only repositories cannot be pruned