Reclaiming disk space by obliterating files

A version management system maintains the history (metadata) of what operations were performed on which files.

If certain files and their history are no longer in use, you might want to recover disk space on the central server. You can do one of the following:

  • Move them into an archive depot by using the p4 archive command. If you later decide you want to use those file and recover their history, use the p4 restore command.
  • Permanently delete the files by using the p4 obliterate command. One use case is to eliminate a submit or a branch that was created by mistake. However, the operations of p4 obliterate are computationally expensive. Avoid using p4 obliterate during peak usage periods because a large amount of metadata must be processed.
  • Permanently delete the files but retain the metadata by using the p4 obliterate -p command. This option recovers the disk space of the files, yet reduces the amount of time the command runs because metadata is not processed.
Warning

Use p4 obliterate with caution. This is the one of only two commands in Helix Server that actually remove file data. (The other command that removes file data is the archive-purging option for p4 archive.)

Warning

Do not use operating system commands (erase, rm, and their equivalents) to remove files from the Helix Server root by hand.

By default, p4 obliterate filename does nothing. It merely reports on what it would do. To actually destroy the file and its metadata, use p4 obliterate -y filename.

To destroy only one revision of a file, specify only the desired revision number on the command line. For instance, to destroy revision 5 of a file, use:

$ p4 obliterate -y file#5

Revision ranges are also acceptable. To destroy revisions 5 through 7 of a file, use:

$ p4 obliterate -y file#5,7
Warning

If you intend to obliterate a revision range, be certain you’ve specified it properly. If you fail to specify a revision range, all revisions of the file are obliterated.

The safest way to use p4 obliterate is to use it without the -y flag until you are certain the files and revisions are correctly specified.