Don’t lose your metadata when backing up to a flat archive
Backup & Recovery (Rsync/Tar/Dd)
Don’t lose your metadata when backing up to a flat archive
🧩 The Challenge
You finally got around to creating a tarball of your project directories only to realize later that the permissions were totally butchered during the restore. I’ve wasted hours manually chowning files because I forgot that standard archives don’t always preserve the ownership info you expect.
💡 The Fix
Start using the explicit flags to force tar to keep those attributes intact. It’s the difference between a working restoration and a pile of locked files that nobody can touch.
tar --xattrs --selinux --acls -cvpf archive_name.tar.gz /path/to/data
⚙️ Why It Works
Adding those specific switches tells the archive to grab the extended attributes, security contexts, and access control lists rather than just dumping the plain files. Without them, you’re just getting the data but losing the guts of how your system actually governs access.
🚀 Pro-Tip: Always pipe your tar command through pigz if you’ve got multiple cores; it makes compression way less of a bottleneck.
Linux Tips & Tricks | © ngelinux.com | 9/24/2026
