Backup & Recovery (Rsync/Tar/Dd)
Stop tar from silently skipping your symlinks during migrations
🧩 The Challenge
Pulled a massive backup of a web root last week only to realize every single one of my application symlinks was replaced by the actual file content. It turned a quick restore into a multi-hour headache of manually fixing broken dependency paths.
💡 The Fix
You need to tell tar to keep the symlink references instead of dereferencing them. It’s a lifesaver when you’re moving directories that rely on relative links.
tar -cvhpf backup.tar /path/to/data
(Wait, to fix the symlink issue, use this instead:)
tar -cvpf backup.tar /path/to/data
⚙️ Why It Works
The ‘h’ flag in tar stands for dereference, which is usually the default setting that gets people into trouble; omitting it forces tar to preserve the symlink inode rather than following it to the target file.
🚀 Pro-Tip: Always run a quick tar -tf on your archive before deleting the source, just to verify those symlinks show up as links and not massive duplicates of your target files.
Linux Tips & Tricks | © ngelinux.com | 7/29/2026
