Stop losing your file permissions during backups

Backup & Recovery (Rsync/Tar/Dd)

Stop losing your file permissions during backups

🧩 The Challenge

Everyone thinks a basic tar command is safe until they go to restore a backup and realize every single file is now owned by the user who ran the extract. I’ve spent way too many nights manually fixing chowns because I forgot that standard archives don’t always preserve the metadata you think they do.

💡 The Fix

You need to tell tar explicitly to hang onto the original ownership information when you create the archive. It’s a simple flag, but it’s the difference between a functional recovery and a complete mess of permission errors.

tar --xattrs --selinux --acls -cvpzf backup.tar.gz /path/to/data

⚙️ Why It Works

Adding these specific flags forces tar to capture the extended attributes, SELinux security contexts, and access control lists that usually get stripped out by default. Without these, your restored service will likely throw permission denied errors everywhere because the security labels didn’t make the trip.

🚀 Pro-Tip: Use the -p flag to ensure those permissions are actually applied when you run the extraction later.

Linux Tips & Tricks | © ngelinux.com | 8/30/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted