Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 CLI Documentation | 2026.1

# p4 archive

Archive obsolete revisions to an archive depot.

## Syntax

    p4 [g-opts] archive [-n -h -p -q -t -z] -D depot FileSpec[revSpec]

Syntax and naming conventions

## Description

This command enables a P4 Server user with admin access to transfer the specified revisions of versioned files into the archive depot A special depot into which versioned files (also known as archive files) can be transferred. See also 'depot'. on the target server The immediately upstream server for replica servers, edge servers, standby servers, proxies and brokers. See also 'upstream server' and 'central server'., not replicas.

When files are moved into an archive depot, their last action is changed to `archive`.

Commands that access file content, such as `p4 sync` and `p4 diff`, skip `archive` revisions. Commands that do not require access to file content, such as `p4 filelog`, continue to report metadata concerning the archived revisions.

You can use `p4 archive -n` for testing purposes before mounting the file system associated with the archive depot. Storage for the archive depot must be mounted before running this command without the `-n` option.

Task streams must be unloaded prior to the task stream file revisions being archived to an archive depot.

If you want to disable server locks when running the `p4 archive` command, set the value of the `server.locks.archive` configurable to `0`.
The following commands permanently remove file data:

- `p4 archive -p`
- `p4 obliterate -y`

### Criteria without -z

Without the -z option, the command archives only revisions that meet all four criteria:

1. Stored in full (+F) or compressed (+C) format, rather than RCS format
2. Located in a local depot (not a `remote` or another `archive` depot)
3. Not copied or branched from another revision
4. Not copied or branched to another revision

### Criteria with -z

With the -z option, the command archives only revisions that meet these two criteria:

1. Stored in full (+F) or compressed (+C) format, rather than RCS format
2. Located in a local depot (not a `remote` or another `archive` depot)

which includes any files that have lazy copies A method to conserve disk space by referencing files instead of duplicating their content. or are lazy copies.

## Options

Option | Description
--- | ---
`-D depot` | Specify an archive depot to which files are to be archived.
`-h` | Do not archive head revisions.
`-n` | Do not archive revisions. Instead, report on which revisions would have been archived.
`-p` | For the specified files in the archive depot, remove the physical file revisions but retain the revision history with the latest action being set to `purge`. File contents are no longer accessible from `p4 restore`. If you want to retain the metadata of purged files, do one of the following: use the -p option of p4 obliterate (recommended) perform the two-step sequence of p4 archive followed by p4 archive -p (time-consuming)
`-q` | Quiet mode, which suppresses messages about skipped revisions.
`-t` | Archive text files (or other revisions stored in delta format, such as files of type `binary+D`)
-z | Includes any files that have lazy copies A method to conserve disk space by referencing files instead of duplicating their content. or are lazy copies. See Criteria with -z.
`g-opts` | See Global options.

## Usage notes

Can file arguments use revision specifier? | Can file arguments use revision range? | Minimal access level required
--- | --- | ---
Yes | Yes | `admin`

- To archive files stored in delta format, use the `-t` option.
There might be a computational cost associated with the manipulation of large numbers of RCS deltas.
- If a revision is stored in an archive depot, and the stored revision is accessible to the versioning service, a user can determine which archived revision to restore by using p4 print:

  `p4 print -A -o myOutputFile //archive/depot/myFile`

  This command redirects all the versions of the archived file to myOutputFile. The user can then request that a P4 Server Administrator use `p4 restore` to restore one or more versions of the file.

  A user with admin access can run p4 fstat -Ob to see the path, revision, type, full and relative local paths of the server archive file.

## Examples

`p4 archive file#3` | Archive revisions `1` through `3` of file If a single revision is specified as a file argument, `p4 archive` implicitly targets revisions #1 through the specified revision for archiving
`p4 archive file#3,3` | Archive revision `3` of file To archive only a single revision `rev`, use the form p4 archive file#rev,rev

To archive files stored in delta format, use the `-t` option:

`p4 archive -D archives -t //depot/....txt` | Use the `...` wildcard to archive the files with the `.txt` extension.
``p4 archive -D archives -t //depot/....txt@3,3`` | Use the `...` wildcard to archive the files with the `.txt` extension that belong to changelist `3`.
``p4 archive -D archives -t //depot/....txt@3`` | Use the `...` wildcard to archive the files with the `.txt` extension that belong to changelists `1` through `3`.

There might be a computational cost associated with the manipulation of large numbers of RCS deltas.

## Related commands

To create a depot | `p4 depot`
To restore files from an archive depot | `p4 restore`
To obliterate files without archiving them | `p4 obliterate`

Your search for returned results