Backup & Recovery (Rsync/Tar/Dd)
Keep your file permissions when moving data with tar
đź§© The Challenge
You finally moved that massive web directory to a new server, only to realize half the scripts are now owned by your local user and the permissions are totally mangled. I’ve wasted an entire afternoon re-chmodding directories because I didn’t think about the user IDs on the destination box.
đź’ˇ The Fix
Use the specific flags that force tar to preserve the original ownership and permission bits exactly as they were on the source. It saves you from a headache when your web server suddenly loses access to its own storage.
tar --numeric-owner --xattrs --acls -czvf backup.tar.gz /path/to/data
⚙️ Why It Works
Setting the numeric owner flag tells the system to store the literal user and group IDs rather than trying to map them to usernames that don’t exist on the target machine. Including extended attributes and ACLs ensures those obscure security policies don’t get left behind during the transfer.
🚀 Pro-Tip: Always double-check your umask before extracting the archive, or it might override your carefully preserved bits anyway.
Linux Tips & Tricks | © ngelinux.com | 7/15/2026
