Create Smart Archiving Policy

JFrog Platform Administration Documentation

Content Type
Administration / Platform

This topic outlines how to create a smart archiving policy. You create the smart archiving policy to archive unintended packages from Active Artifactory Instance to Archive Artifactory Instance.

Ideal_Smart_Archiving_Workflow.png

Authorization

Activity

Platform Admin

Project Admin

Application User

Create Smart Archiving Policy 

Note:

Only from allocated projects

To create Archive Retention policies, follow these steps:

Important

Archive Evidence

From Artifactory Version 7.117, added support for the archival of evidence associated with any packages. This enhancement ensures that relevant evidence is preserved as part of your archiving strategy, streamlining your package management process.

Note

Please note that in Artifactory versions prior to 7.117, if you archive packages that have associated evidence, the evidence will not be archived. When restoring packages archived in these earlier versions, only the packages themselves will be restored, and any associated evidence will not be restored.

  1. As per the User persona, you can work with the contexts as described below:

  2. In the Retention Policies page, from the Create Policy drop-down list, click Archive Policy.

  3. Configure the following in the Create New Archive Policy page:

    HC_CreatePolicy.png

    Field

    Description

    Media

    Policy Name

    Enter a unique and meaningful name for the policy.

    HC_CreatePolicyNameDescription.png

    Description

    Enter information regarding why this policy was created, and details that help users understand its configuration.

    Policy Scope

    Include Projects / Include All Projects

    Note

    This setting is applicable only at the global level for Platform Admins. It does not appear when creating a policy at the project level. When this setting is visible, it is mandatory.

    Select the projects where you want the policy to apply, or choose Include All Projects to run the policy across all projects on the platform. You can also select Unassigned Repositories to apply the policy to repositories not linked to any projects.

    HC_CreatePolicyPolicyScope.png

    Package Types

    Select one or more of the package types you want to archive.

    Note

    If a policy includes a repository with retention settings, packages designated for retention may be inadvertently removed.

    Include Repositories

    • Enter one or more patterns for the repository names where you want the archive policy to apply, then click Add. Alternatively, you can select Include All Repositories or specify explicit repository names. At least one pattern or explicit name is required, as only packages in repositories matching these will be archived.

    • Auto-complete will suggest options based on the project and package type, and both local and federated repositories are supported.

    Note

    It is not possible to specify a path within a repository.

    Note

    Set Patterns: Use wildcards at the end to match any suffix, or at the start to match any prefix

    For example, npm-local* includes all repositories starting with npm-local.

    Regex is not supported.

    Exclude Repositories

    Enter patterns or explicit repository names to exclude from the archive policy. Auto-complete will suggest options based on the project and package type.

    Note

    Set Patterns: Use wildcards at the end to match any suffix, or at the start to match any prefix.

    For example, npm-local* excludes all repositories starting with npm-local.

    Regex is not supported.

    Include Package Name Pattern

    Enter a pattern for a package name or an explicit package name for the archive policy, then click Add or select Include All Packages. Only one pattern or explicit name is allowed.

    Note

    Set Patterns: Use wildcards at the end to match any suffix, or at the start to match any prefix.

    For example, mypackage* includes all packages starting with mypackage.

    Regex is not supported.

    Exclude Package Name

    Enter explicit package names to exclude from the policy and click Add. Only explicit names are accepted and not patterns.

    Include Package Version Pattern

    Enter a pattern for a package version or an explicit package version for the policy.

    Note

    Set Patterns: Use wildcards at the end to match any suffix, or at the start to match any prefix.

    For example, 1.0.* includes all packages starting with 1.0.

    Regex is not supported. Only 1 pattern or explicit version can be entered.

    Available from V 7.127 (Cloud) and V 7.125.7 (Self-managed)

    Exclude Package Version Patterns

    Enter explicit package version to exclude from the policy. Only explicit versions are accepted and not patterns.

    Available from V 7.127 (Cloud) and V 7.125.7 (Self-managed)

    Policy Conditions

    Time-based/Version-based

    Do one of the following to define under what conditions the policy finds packages:

    Note

    A policy must include one of the two conditions below:

    • Time-Based

      • Packages Older Than

      • Packages Not Downloaded Since

    • Version-Based: Number of Latest Versions to Keep.

    We recommend using the Packages Not Downloaded Since condition to prevent the archive of packages that are currently in use.

    • Time-based

      • Select Packages Older Than checkbox, and apply the number of days/weeks/months/years for the older packages.

        Note

        A day in this context is a 24-hour period from the moment the policy is executed. Other units are considered as follows:

        • 1 week = 7 days

        • 1 month = 30 days

        • 1 year = 365 days

        The system will convert them to appropriate time unit if the matching value is entered. For example, if you enter 7 days, the system changes it to 1 Week.

        When enabled, this setting archives packages based on their creation date. For example, you can archive packages created more than a year ago. By default, it is set to archive packages created more than 2 years ago.

      • Select Packages Not Downloaded Since checkbox, and apply the number of days/weeks/months/years for the not downloaded packages.

        Note

        A day in this context is a 24-hour period from the moment the policy is executed. Other units are considered as follows:

        • 1 week = 7 days

        • 1 month = 30 days

        • 1 year = 365 days

        The system will convert them to appropriate time unit if the matching value is entered. For example, if you enter 7 days, the system changes it to 1 Week.

        When enabled, this setting archives packages based on their last download date. For example, it can archive packages that have not been downloaded in the past year. By default, it is set to archive packages that have not been downloaded for more than 2 years.

        Note

        If a package was never downloaded, the policy will archive it based only on the age condition (Packages Older Than).

    • Version-based - Number of Latest Versions To Keep

      Select the number of the latest versions to keep. The archive policy will archive all versions that exceed this number, with the latest version always excluded from archiving.

      Note

      • This setting appears only if Version-based is selected.

      • Versions are determined by creation date.

      • Not all package types support this condition. For information on which package types support this condition, refer to Smart Archiving Supported Packages.

    • Property-based

      Enter the property name and value applied to the lead artifact of a package. Packages with this property will be archived. For information, refer to Smart Archiving Supported Packages.

    HC_CreatePolicyPolicyConditionsVersion.png
    HC_CreatePolicyPolicyConditionsTime.png

    Exclude based on property

    Enable the checkbox and enter the property name and value applied to the lead artifact of a package. Packages with this property will be excluded from archiving. For information, refer to Smart Archiving Supported Packages.

    Additional Settings

    Cron Expression

    A cron expression is a string comprised of five or six fields separated by spaces. Each field represents a different unit of time, which collectively define the schedule for policy execution. The standard format is as follows:

    * * * * * *     (Seconds - Optional)
    | | | | | |
    | | | | | +---- Day of the week (0 - 6) (Sunday=0)
    | | | | +------ Month (1 - 12)
    | | | +-------- Day of the month (1 - 31)
    | | +---------- Hour (0 - 23)
    | +------------ Minute (0 - 59)
    +-------------- Second (0 - 59) (Optional)

    Note

    This cron expression must follow the Quartz scheduler format as used in the CronTrigger class. It differs from the standard Unix cron format. For example, Quartz supports a sixth optional field for seconds and uses ? for non-specific values. Refer to the Quartz documentation for more details: Quartz Cron Expression Format

    Example Cron Expression

    To illustrate how to construct a cron expression, consider the example below:

    Expression: 0 0 2 * * ?

    • 0 - At second 0

    • 0 - At minute 0

    • 2 - At hour 2 (2:00 AM)

    • * - Every day of the month

    • * - Every month

    • ? - No specific value for the day of the week

    This expression schedules the policy to run every day at 2:00 AM.

    Guidelines for Scheduling

    • Run Interval: The minimum interval between policy executions is 6 hours. If you attempt to set a cron expression that results in a runtime shorter than this duration, you will encounter an error when saving the configuration.

    • Off-Hours Scheduling: It is recommended to tune your cron expression so that policies run during off-hours. This helps to reduce the impact on system performance during peak usage times.

    Leaving the Cron Expression Empty: If you leave the cron expression empty, you can only Run Smart Archiving Policy Manually manually. This means that there will be no automatic scheduling and the policy will not run unless you initiate it.

    HC_CreatePolicyAdditionalSettings.png

    Max Run Duration

    This setting limits the maximum duration the policy can run when enabled. The maximum allowed duration is 5 hours.

    Note

    The policy stops before the completion of the run if it exceeds the applied run duration. In one run, within this duration, it archives all or part of your packages depending on the size and number of items. If there are any pending packages to be archived, they are archived incrementally in the next scheduled run and the subsequent runs.

    Skip Trash Can

    When enabled, this setting will cause packages to be permanently deleted from Artifactory instance without an option to restore them immediately after the archive policy is executed, bypassing the Trash Can repository. To restore, refer to Restore Archived Packages.

    Note

    If you want deleted items to be transferred to the trash can, you must enable the global Trash Can setting. To learn more, refer to Trash Can Settings.Trash Can Settings

    The packages are copied from Active Artifactory Instance to Archive Artifactory Instance, and then deleted in the Active Artifactory Instance.

  4. Click Save to save the policy.

    The newly created smart archiving policy appears in the Policies list and executes on the scheduled date and time.