Keep your metadata from going AWOL when you restore backups

Backup & Recovery (Rsync/Tar/Dd)

Keep your metadata from going AWOL when you restore backups

🧩 The Challenge

You finally spent all afternoon wrestling a backup to disk, only to find that every file is now owned by root with the wrong permissions. It is a nightmare when your web server refuses to read files it supposedly owns.

💡 The Fix

Throw the right flags into your archive command to force it to preserve ownership and mode bits. Most people forget this and lose their sanity during the restore.

tar -xvpzf backup.tar.gz -C /target/directory/

⚙️ Why It Works

Adding the p flag tells tar to extract the original file permissions, while the -p and ownership settings keep your UID and GID mapping intact. It saves you from running a massive chown -R recursive loop that takes ages to finish.

🚀 Pro-Tip: Always run a dry run with -t first to check the internal structure before you actually overwrite your production data.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted