Does unrar Preserve File Timestamps by Default?
When extracting files from a RAR archive using the unrar
utility, the tool preserves original file modification timestamps by
default. Users extracting files through standard commands do not need to
supply extra arguments to keep the original modification dates intact,
as the extraction process automatically applies the stored metadata to
the newly unpacked files.
Default Timestamp Behavior
When a RAR archive is created, it automatically stores the last
modification time (mtime) of each file. During extraction
via standard commands such as unrar x archive.rar or
unrar e archive.rar, unrar reads this metadata
and restores the exact original modification timestamp for each
extracted file.
However, standard filesystems track three distinct timestamps:
- Modification Time (
mtime): Preserved by default. - Creation/Birth Time (
ctime/crtime): Not preserved by default unless specifically captured during compression and supported by the target operating system. - Access Time (
atime): Set to the time of extraction by default unless explicitly archived and restored.
Managing Timestamps
with the -ts Switch
To control how timestamps are handled, unrar provides
the -ts (time stamp) switch. This allows fine-grained
control over modification, creation, and access times during
unpacking:
- Restore All Timestamps: If the archive contains
creation and access times, you can restore them alongside modification
times using:
unrar x -ts archive.rar - Ignore Stored Timestamps: If you want extracted
files to reflect the current system time instead of the original archive
dates, disable timestamp restoration with
-ts-:unrar x -ts- archive.rar - Target Specific Timestamps: You can selectively
restore specific attributes using modifier letters:
-tsm+: Restores modification time (default behavior).-tsc+: Restores creation time (if present in the archive).-tsa+: Restores last access time.
Directory Timestamps
While file modification times are restored cleanly, directory
timestamps can behave differently depending on the operating system.
When unrar extracts files into a folder, the host
filesystem updates the folder’s modification time to reflect that new
items were added inside it. Using full path extraction
(unrar x) ensures that directory structures and metadata
are handled as accurately as the filesystem permits.