How do I delete old packages in local repository server?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux Server (RHEL)

Issue

  • On local repository created with the reposync command:
    • How do I delete the old packages in a repository?
    • How to keep only the latest version of packages in a repository?

Resolution

  • Use repomanage --old to list older packages, and remove them:

      # rm -f $(repomanage --old <TARGET_DIR>)
    
  • For AppStream repository, use repomanage --new to list packages from latest streams, and remove all the others:

      # find <TARGET_DIR> -type f -name \*.rpm | grep -vf <(repomanage --new <TARGET_DIR>) | xargs -I % rm -v %
    
SBR
Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.