Extract a tar.gz archive without overwriting files
extract tar.gz to directory | restore backup from tar.gz | extract archive without overwriting | tar skip existing files | tar | restore | backupCaution: This command changes the system. Understand what it does before you run it.
mkdir -p /tmp/restore && tar -xzf /var/backups/example.com-httpdocs-2026-10-09.tar.gz -C /tmp/restore --skip-old-filesCreates the target directory if needed and extracts the archive there. --skip-old-files leaves existing files untouched, so an accidentally wrong target does not overwrite data. The safest choice is an empty directory from which you then copy back selectively.
Note: Owners from the archive are only restored when extracting as root, otherwise all files belong to the user running the command.
Also searched as
- extract tar.gz to directory
- restore backup from tar.gz
- extract archive without overwriting
- tar skip existing files