Stop losing your metadata when you move massive datasets with tar
Backup & Recovery (Rsync/Tar/Dd)
Stop losing your metadata when you move massive datasets with tar
🧩 The Challenge
You finally decide to migrate that ancient home directory or a legacy web root to a new server, only to realize the permissions are completely garbled on the other side. Nothing ruins a migration faster than a root-owned mess of files that your app user can’t actually touch.
💡 The Fix
Start using the explicit preserve flags in your tar archive creation to lock in ownership and mode bits. It makes moving files between identical UID/GID setups a painless affair instead of a permissions nightmare.
tar --xattrs --selinux --acls -cpzf backup.tar.gz /path/to/data
⚙️ Why It Works
Adding those three specific flags forces tar to capture the extended attributes and security contexts that usually get stripped by default. Most people forget about these until they’re staring at a “Permission Denied” error on a fresh production server.
🚀 Pro-Tip: Always pipe your tar command through pigz if you want to crush those CPU cycles and speed up the compression.
Linux Tips & Tricks | © ngelinux.com | 11/14/2026
