Create Smart Archiving Policy

This topic describes how to create a Smart Archiving policy that archives packages from the Active Artifactory Instance to the Archive Artifactory Instance.

Ideal_Smart_Archiving_Workflow.png

Prerequisites:

  • Configure an Archive Artifactory Instance and connect it to the Active Artifactory Instance. For more information, see Configure Smart Archiving Instance.
  • You must be a Platform Admin, or a Project Admin in an allocated project, to create an archive policy. Non-admin users cannot create archive policies. To grant this permission to a Project Admin, see Grant Permission to Project Admin.

Create a Smart Archiving Policy

❗️

Warning

In Artifactory versions before 7.117, associated evidence isn't archived with the packages. When you restore those packages, only the packages are restored.

From Artifactory version 7.117, Smart Archiving archives evidence associated with the packages.

To create an archive policy:

  1. From the Administration module, select Artifactory Settings > Retention Policies.

  2. In the Retention Policies page, from the Create Policy dropdown list, select Archive Policy.

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

    • Policy Details

      • Policy Name: Enter a unique and meaningful name for the policy.

      • Description: Enter information regarding why this policy was created, and details that help users understand its configuration.
    • Policy Scope: Define where the policy runs. Set the stages, projects, package types, repositories, paths, package names, and versions that the policy includes or excludes.

      • Include Stages or Include All Stages: Select the stages to which the policy should apply, or select Include All Stages to run the policy across all stages in the JFrog Platform.

      • Include Projects or Include All Projects:

      Select the projects to which the policy should apply, or select Include All Projects to run the policy across all projects in the JFrog Platform. You can also select Unassigned Repositories to apply the policy to repositories not linked to any projects.

      📘

      Note

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

      • 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 Repository Patterns: 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 suggests options based on the project and package type, and both local and federated repositories are supported.
      📘

      Note

      Enter repository names or name patterns in this field. To include or exclude folders inside a repository, use Include Path Patterns or Exclude Path Patterns.

      📘

      Note

      • 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.
      • Regular expressions aren't supported.
      • If the policy includes a local repository configured for remote push replication, deletions from that repository are replicated to the remote targets.
      • Exclude Repository Patterns: Enter patterns or explicit repository names to exclude from the archive policy. Auto-complete suggests options based on the project and package type.
      📘

      Note

      • 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.
      • Regular expressions aren't supported.
      • Include Path Patterns (optional): Enter one or more folder path prefixes to include in the archive policy. Use this option to narrow the policy scope to specific repository paths within the defined repositories. Available from Artifactory 7.146.7 for self-managed.
      📘

      Note

      • Use wildcards at the start or end of a folder path. For example, releases/* matches paths that start with releases/, */production matches paths that end with /production, and com/example/releases is an exact path match.
      • Double wildcards (**) and wildcards in the middle of a path aren't supported.
      • You can add up to 10 paths.
      • Exclude Path Patterns (optional): Enter one or more folder path prefixes to exclude from the archive policy. Use this option to include all packages within the defined repositories except for the packages whose path matches the exclude patterns. Available from Artifactory 7.146.7 for self-managed.
      📘

      Note

      • Use wildcards at the start or end of a folder path. For example, snapshots/* excludes paths that start with snapshots/, */dev excludes paths that end with /dev, and com/example/internal is an exact path match.
      • Double wildcards (**) and wildcards in the middle of a path aren't supported.
      • You can add up to 10 paths.
      • 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

      • 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.
      • Regular expressions aren't supported.
      • Exclude Package Name: Enter explicit package names to exclude from the policy and click Add. You can enter only explicit names, not patterns.

      • Include Package Version Pattern: Enter a pattern for a package version or an explicit package version for the policy, or select Include All Versions.

      📘

      Note

      • 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.
      • Regular expressions aren't supported.
      • You can enter only one pattern or explicit version.

      Available from version 7.127 for SaaS and version 7.125.7 for self-managed.

      • Exclude Package Version Patterns: Enter explicit package versions to exclude from the policy. You can enter only explicit versions, not patterns.

      Available from version 7.127 for SaaS and version 7.125.7 for self-managed.

    • Policy Conditions: Define when the policy selects packages for archiving.

      Select one or more conditions. Packages Older Than, Packages Not Downloaded Since, and Property are combined with logical AND. A package is archived only when it meets every selected condition. Keep Last N Versions excludes the newest N versions from archiving.

      • Packages Older Than: Archives packages based on their creation date, regardless of whether they have been downloaded.
      • Packages Not Downloaded Since: Archives packages based on their last download date. The default is 2 years. If a package was never downloaded, it is archived only if its creation date is older than the specified Not Downloaded Since period. Use this condition to prevent the archiving of packages currently in use.
      • Property: Archives packages based on a property key-value pair applied to the lead artifact. For more information, see Smart Archiving Supported Packages.
      • Keep Last N Versions: Enter how many of the newest versions to keep. Those versions aren't archived, even when they meet the other conditions. The latest version is always kept.
      • Exclude based on property: Select 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 more information, see Smart Archiving Supported Packages.
      📘

      Note

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

      • 1 week = 7 days
      • 1 month = 30 days
      • 1 year = 365 days

      Artifactory converts them to the appropriate time unit if you enter a matching value. For example, if you enter 7 days, Artifactory changes it to 1 week.

      📘

      Note

      • Versions are determined by creation date.
      • Not all package types support the Keep Last N Versions condition. For more information, see Smart Archiving Supported Packages.
      • If your archive policy includes a version-based condition, for example Keep Last N Versions, a change in behavior in Helm client 3.18.0 and later causes Helm to create two manifest nodes per version. One is for the tag and one is for the digest. This affects any OCI-compliant repository where Helm charts are stored, including Helm OCI and Docker repositories. Since Artifactory counts each manifest node as a separate version, the policy may retain digest references instead of the human-readable tags used for consumption.

      Behavioral logic when multiple conditions are selected: Packages Older Than, Packages Not Downloaded Since, and Property are evaluated together using logical AND. Keep Last N Versions excludes the newest versions.

      • If you select both Packages Older Than and Packages Not Downloaded Since, the policy archives only packages that meet both conditions. Packages that have never been downloaded are archived only if their creation date is older than the Packages Older Than value.
      • If you also select Keep Last N Versions, packages among the last N versions for their package path are never archived, even when they meet the other conditions.
      • When you select Property with Packages Older Than or Packages Not Downloaded Since, a package must match the property and meet those conditions.

      Example: You select Packages Older Than 12 months, Property prod=true, and Keep Last 5 Versions. The policy archives only packages that are older than 12 months, have the property prod=true, and aren't among the five most recent versions of their package.

    • Additional Settings: Set when the policy runs, how long a run can continue, and whether deleted packages on the active instance bypass the Trash Can.

      • Cron Expression: A cron expression uses the Quartz scheduler format. It has six required fields, separated by spaces, in this order: seconds, minutes, hours, day of the month, month, and day of the week. An optional seventh field specifies the year.
      * * * * * *
      | | | | | |
      | | | | | +---- 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)
      📘

      Note

      This cron expression must follow the Quartz scheduler format used by the CronTrigger class. It differs from the standard Unix cron format. Quartz requires a seconds field and uses ? for non-specific values. An optional seventh field specifies the year. For more information, see Quartz Cron Expression Format.

      Example Cron Expression

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

      Expression: 0 0 2 * * ?

      • 0 - At second 0
      • 0 - At minute 0
      • 2 - At hour 2, or 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 the cron expression schedules runs less than 6 hours apart, you get an error when you save the policy.
      • Off-Hours Scheduling: 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, the policy has no automatic schedule. After you enable it, you can only Run Smart Archiving Policy Manually.

      • 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, packages copied to the Archive Artifactory Instance are deleted from the Active Artifactory Instance without being moved to the Trash Can. You can still restore them from the Archive Artifactory Instance. For more information, see Restore Archived Packages.
      📘

      Note

      To keep a copy of the deleted packages in the Trash Can on the active instance, leave Skip Trash Can cleared and enable the global Trash Can setting. For more information, see Trash Can Settings.

      Artifactory copies the packages from the Active Artifactory Instance to the Archive Artifactory Instance, and then deletes them from the Active Artifactory Instance.

  4. Click Save.

    The policy appears in the Policies list and is disabled. It doesn't run until you enable it.

  5. Perform a dry run and review which packages would be archived. For more information, see Perform Dry Run on a Smart Archiving Policy.

  6. Enable the policy. An enabled policy runs on the schedule you set, or you can run it manually. For more information, see Enable or Disable Smart Archiving Policy and Run Smart Archiving Policy Manually.

What Happens After You Enable the Policy

After you enable a Smart Archiving policy, Artifactory runs it on the schedule you defined, or when you start it manually, and archives the packages that match the policy conditions.

After you enable the policy:

  • Enabled policies with a cron expression run on the scheduled date and time.

    You can also run an enabled policy manually. For more information, see Run Smart Archiving Policy Manually.

📘

Note

We recommend not to run more than 10 policies at the same time.

The archive policy doesn't execute when an ongoing mandatory task is in progress (for example, Garbage Collection). To Run Smart Archiving Policy Manually or Perform Dry Run on a Smart Archiving Policy, try at a later time.

  • Artifactory archives the packages, along with the associated metadata, and moves them to the Archive Artifactory Instance.
  • When an item is archived, Artifactory dynamically creates dedicated archiving repositories in the Archive Artifactory Instance.
  • As the archive process progresses, View All Smart Archiving Runs from the Active Artifactory Instance.

Frequently Asked Questions

This section provides answers to frequently asked questions about creating a Smart Archiving policy.

plusFAQs
Q: What permissions do I need to create an archive policy?

A: Platform Admins can create archive policies. Project Admins can also create them, but only from their allocated projects. Non-admin users cannot create archive policies. To grant a Project Admin this permission, see Grant Permission to Project Admin.

Q: Is package evidence archived along with the packages?

A: Artifactory 7.117 and later archive the evidence associated with a package. In earlier versions the evidence isn't archived, and restoring those packages restores only the packages themselves.

Q: How are multiple policy conditions evaluated together?

A: Packages Older Than, Packages Not Downloaded Since, and Property are combined with logical AND. A package is archived only when it meets every selected condition. Keep Last N Versions excludes the newest versions from archiving. See Create a Smart Archiving Policy.

Q: What happens if I leave the cron expression empty?

A: The policy has no automatic schedule. After you enable it, it runs only when you start it manually. The minimum interval between scheduled executions is 6 hours.

Q: How can I preview what a policy would archive before enabling it?

A: Perform a dry run to see which items would be archived without archiving them, then review the results before you enable the policy.

Q: How many archive policies can run at the same time?

A: JFrog recommends running no more than 10 policies simultaneously. Archive policies also don't execute while a mandatory task such as Garbage Collection is in progress.

Related Topics


Did this page help you?