How to Restore an Overwritten Artifact

Daniel Poterman
2020-12-06 07:21

Subject
How to restore an overwritten Artifact

Description
In Artifactory, an artifact may be overwritten as a result of the deployment of different artifacts with the same name and path. The two locations from which you can restore “lost” artifacts are the:

  • Trash Can
  • Filestore

Resolution
Taking these in order, to restore an artifact from the Trash Can, you must first verify that the Trash Can is enabled and that you did not exceed the retention period (which is set to 14 days by default). If you are within this period, you can restore your wayward file finding it in the Trash Can, right-clicking on it, selecting Restore, and opting to Choose a Custom Path, which will guarantee that the restored file won’t overwrite an existing file. More information about the Trash Can is available HERE.
User-added image

User-added image

Alternatively, if:

  • your Trash Can hasn’t been enabled
  • the Garbage Collection process hasn’t cleaned up your Filestore yet, and
  • you have the checksum value (SHA-1) of your overwritten artifact 

you should be able to locate it in and restore it from the Filestore, which is organized in a directory structure where each directory is named for the first two (2) characters of the checksum value of a given artifact. The screenshot below shows an example of the Filestore structure:
User-added image
and within "0f" I have the following artifact:
User-added image
After you have found the overwritten artifact:

  1. Copy it to a location outside of the Filestore.
  2. Change its name from its current SHA-1 name to a new, desired name.
  3. Upload the newly-named artifact back to a desired path in Artifactory.

More information about Artifactory’s Checksum-Based Storage can be found HERE.
The above-mentioned Links are for Artifactory version 6.x.

In Artifactory version 7.x, these artifact restoration processes are very similar. For version-specific details, please consult the links below to access pertinent documentation: