# Mirroring repositories with p2

p2 provides two applications that support copying (mirroring) the content of remote repositories to a local repository. There is also a p2.mirror ant task.

## Mirroring an artifact repository

The artifact mirroring application supports duplicating a complete artifact repository into a target repository. To perform this operation you simply need an eclipse installation that contains the `org.eclipse.equinox.p2.artifact.repository` bundle. The following command will copy the complete contents of a source repository into the destination repository. If the destination repository does not already exist, the mirroring application will create a new repository with the same properties as the source.

       <eclipseInstall>\eclipse.exe
       -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication
       -source http://download.eclipse.org/releases/ganymede
       -destination file:d:/artifactLocalRepository/

### Arguments description

- -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication: the application ID.
- -source <source location>: the artifact repository to mirror from.
- -destination <destination location>: the artifact repository to mirror to.

### Additional arguments

- -writeMode clean: removes all artifacts from the destination repository before performing the mirroring process.
- -verbose: enables error messages and error logging.
- -ignoreErrors: ensures the mirroring application continues to run in the event of an error during the mirroring process.
- -raw: instructs the mirroring application to copy the exact artifact descriptors from source into the destination instead of initializing new artifact descriptors with properties from the source descriptors.
- -compare: instructs the mirroring application to perform a comparison when a duplicate artifact descriptor is found.
- -comparator <comparator ID>: specifies which comparator the mirroring application should use to compare artifact descriptors. Uses the "MD5 Comparator" if no comparator is defined which compares the MD5 hash property of the artifact descriptors.
- -compareAgainst <baseline location>: specifies the location of a known good repository. When specified the mirror application will compare all artifacts from the source to the baseline with precedence given to artifacts found in the baseline.
- -destinationName <destination name>: specifies what the destination repository should be named. If no name is specified, the source repository's name will be used as the destination's name if no repository exists at the destination.

## Mirroring a metadata repository

The metadata mirroring application supports copying a complete metadata repository into a target repository. To perform this operation you simply need an eclipse installation that contains the `org.eclipse.equinox.p2.metadata.repository` bundle. The following command will copy the complete source repository into the destination repository. If the destination repository does not already exist, the mirroring application will create a new repository with the same properties as the source.

        <eclipseInstall>\eclipse.exe
       -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication
       -source http://download.eclipse.org/releases/ganymede
       -destination file:d:/metadataLocalRepository/

### Arguments description

- -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication: the application ID.
- -source <source location>: the metadata repository to mirror from.
- -destination <destination location>: the metadata repository to mirror to.

### Additional arguments

- -writeMode clean: removes all installable units from the destination repository before performing the mirroring process.
- -destinationName <destination name>: specifies what the destination repository should be named. If no name is specified, the source repository's name will be used as the destination's name if no repository exists at the destination.