Site icon New Generation Enterprise Linux

Keep your extended attributes when archiving data

Backup & Recovery (Rsync/Tar/Dd)

Keep your extended attributes when archiving data

đź§© The Challenge

Backing up data with tar is standard practice until you realize your SELinux contexts or ACLs didn’t survive the trip. I’ve wasted an entire afternoon re-labeling files after a restore because I forgot a single flag.

đź’ˇ The Fix

Use the extended attribute flags to make sure tar preserves all that metadata, otherwise, you’re just moving plain data and losing the security context. It’s the difference between a functional restore and a total headache.

tar --xattrs --xattrs-include='*' -cvzf backup.tar.gz /path/to/data

⚙️ Why It Works

Adding the xattrs flag tells tar to pack the extended file attributes into the archive, and the include wildcard ensures everything from ACLs to security labels gets caught in the net. Without explicitly including them, tar tends to ignore the extra metadata bits that keep your server from throwing access denied errors.

🚀 Pro-Tip: Always verify your archive contents with tar -tvf –xattrs before you delete the original source.

Linux Tips & Tricks | © ngelinux.com | 10/24/2026

0 0 votes
Article Rating
Exit mobile version