I am running this on z/OS and want to copy Unix files from one z/OS image to another.
The tar command is very popular, and works for most people.
The pax command is similar to tar, but It can also save and restore file attributes that cannot be handled by any other format such as: files greater than 8 GB, large UID, and GID values , large time values and z/OS -specific attributes like user audit and auditor audit flags and file format.
You create a file using
pax -o saveext -wf pax_file_name files_to_add
and
pax -ppx -rf pax_file_name
to extract the files.
Thanks to Gwydion Tudur for the pointers about extended attributes.
Using a data set
You can use a data set as an output file for example you specify “//’COLIN.PAX.HTTP2′”
pax -E -f “//’COLIN.PAX.HTTP2′”
This will display the contents of the file, for example if gives
drwxrwxrwx 1 OMVSKERN SYS1 0 Aug 4 10:03 ./
drwxrwxrwx 1 OMVSKERN SYS1 0 Nov 15 2021 ./images/
drwxrwxrwx 1 OMVSKERN SYS1 0 Nov 15 2021 ./images/ihs/
-rwxrwxrwx --s- 1 OMVSKERN SYS1 223 Nov 15 2021 ./images/ihs/administration.gif
-rwxrwxrwx --s- 1 COLIN SYS1 373 Jun 17 2023 ./colin.html
Using a data set makes it more portable, for example it is a data set, not a file in a Unix file system.
File owners
Within the .pax file the file owner is a name. When the file is unpacked, you can use the -p o option to preserves the user ID and group information. On my system userid OMVSKERN has uid 0, and group SYS1 has gid 0. On my newer z/OS system the file got the uid of COLIN on the new system – not from the old system.
Without the -po option, the files get the uid from the userid executing the pax command.