How to Keep Timestamps When Extracting with UnRAR

When extracting compressed archives with UnRAR, preserving accurate directory and file timestamps is essential for maintaining backup integrity and chronological organization. This guide covers the specific command-line switches used in UnRAR to control and preserve timestamps during extraction, explaining how both archive-level and folder-level time attributes are handled.

The Timestamp Switches in UnRAR

To manage timestamps during extraction, UnRAR uses the -ts switch family and the -tk switch, depending on whether you want to preserve the archived folder's original internal timestamp or the timestamp of the archive container itself.

1. Preserving Original Folder Timestamps: -ts

To ensure that extracted files and directories retain their original timestamps stored inside the archive, use the -ts switch.

unrar x -ts archive.rar

The -ts (Time Stamp) switch tells UnRAR to restore the exact time attributes stored in the archive down to high precision. You can also specify exact attributes:

  • -tsm: Restores the modification time.
  • -tsc: Restores the creation time (on supported file systems like NTFS).
  • -tsa: Restores the last access time.
  • -ts+: Restores all available time information.

When extracting with unrar x -ts archive.rar, UnRAR applies the stored modification dates directly to the target folders instead of overwriting them with the current system extraction time.

2. Keeping Archive Time: -tk

If your goal is to prevent any changes to the archive container file's original timestamp or ensure archive-level time tracking, UnRAR provides the -tk switch.

unrar x -tk archive.rar

The -tk (Time Keep) switch instructs the utility to retain the original archive time. While primarily used during archive creation or updates to prevent the .rar file's modification date from advancing, using it alongside extraction guarantees that the archive's own timestamp remains unmodified on the host file system.

To extract an archive with full folder structures and ensure all directory and file dates match the archived records exactly, run:

unrar x -ts+ archive.rar

This command restores complete directory paths (x) while enforcing all stored folder creation, modification, and access timestamps (-ts+).