Keep your tar backups from nuking your path permissions

Backup & Recovery (Rsync/Tar/Dd)

Keep your tar backups from nuking your path permissions

🧩 The Challenge

Everyone thinks tar just grabs files, but if you run it as root, it tries to restore the original ownership and permissions on extraction. I spent an entire afternoon wondering why my web server directory was suddenly owned by a UID that didn’t exist on the new box.

💡 The Fix

Use the flags that tell tar to ignore the metadata inside the archive and just use your current shell’s environment instead. It saves you from manual chown/chmod loops later.

tar --no-same-owner --no-same-permissions -xvf backup.tar.gz -C /target/directory/

⚙️ Why It Works

By flipping these two flags, you tell the tool to discard the stored uid/gid and mode bits, forcing it to inherit the permissions of the directory you’re dropping the files into.

🚀 Pro-Tip: Always double-check where your extraction path actually points before you hit enter, or you might overwrite your own live config files.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted