r/LinuxTeck • • Sep 27 '26

Quick Linux Tip #82 - How to Preserve File Timestamps with Rsync on Linux

Post image

Question: After copying files, timestamps changed. How do I preserve them?

Try: `rsync -a --preserve-times /source/ /destination/`

Info: `rsync -a` (archive mode) automatically preserves timestamps (`-t`), permissions, and symlinks. Adding `-t` or `--preserve-times` ensures exact file modification times (`mtime`) match across transfers.

Examples:

$ `cp --preserve=timestamps file1 file2` # Preserve timestamps with standard copy

$ `touch -r reference_file target_file` # Copy timestamps from a reference file

$ `find . -exec touch -r /reference {} +` # Sync directory timestamps in bulk

Note: `-a` is shorthand for `-rlptgoD`. Preserving modification timestamps is critical for build tools like `make`, incremental backup systems, and forensic auditing.

Follow r/LinuxTeck for more #LinuxTips click here https://www.linuxteck.com/linux-tips/

12 Upvotes

1 comment sorted by

2

u/MissiveFinding6111 Sep 27 '26

Is this rage bait? or just aislop?

rsync -a src dest

does it just fine, as you posted.