If you use
tar you can preserve the ownership of files. However, unless you're root when extracting the file from the tar file, the ownership won't be restored if you don't have the permission.
Note that tar does not compress, it only archives.
As an added bonus,
tar will preserve the permissions of the files and directory.
To use tar and make sure to preserve all ownership and permissions:
tar cpf ~/myarchive.tar folder_to_archive
(take care that tar store the relative or absolute path as well. When extracting if you are a standard user, tar will extract the files relatively to the current folder. But if you are root and you used an absolute path, tar will extract them using the absolute path, potentially overwriting existing files. Read tar documentation and tutorials for all possibilities regarding absolute or relative paths.)
(optionally you can then compress your tar archive using whatever compression tool. Examples:
gzip ~/myarchive.tar or
xz ~/myarchive.tar etc.)
To extract your files:
tar --same-owner xpf ~/myarchive.tar
As a normal user this will extract the files in the current folder, permissions will be kept but user ownership will be lost and group ownership might be lost if you are not part of the group.
But to have all permissions and ownership set correctly you will need to either call this command via
sudo or execute it as a user with enough privileges (usually root).
PS: if on Linux and using the GNU tar, you can preserve in addition some metadata such as ACL, xattr or SELinux. But you need to use special flags to let tar know you want this data to be archived as well. See the GNU tar documentation.