copytree — Make a copy of a file hierarchy while preserving all file attributes

Format

/samples/copytree [–afos] sourcedir [targetdir]

Description

copytree is a REXX sample that enables you to use a number of z/OS® UNIX capabilities. Included is a recursive routine to descend a hierarchical directory. You can also use it to accomplish the following tasks:
  • Retrieve and set attributes for files
  • Read and write files
  • Read and set access control lists (ACLs)
copytree replicates a source tree starting under the source directory within a file system to a target directory. It:
  • Tolerates errors when setting target attributes with messages.
  • Tolerates errors in the source tree, skipping those files.
  • Copies sparse files as sparse files.
  • Handles both symbolic links and external links
  • Does not cross mount points
  • Preserves file links

copytree is installed in the z/OS UNIX file system. Run it as /samples/copytree.

To run it under TSO, copy /samples/copytree to a PDS where REXX execs can be run, or in a PDS to run under TSO.

Restriction: copytree cannot handle files greater than 1 GB in TSO/E.

Guideline: Every attribute that can be set should be copied if you have sufficient authorization.

Options

Any combination of the option flags can be used, with no spaces between flags.

-a
Specifies that the 30,000 node limit warning is not to be issued.
-f
Specifies that full file reads are to be done when copytree is run in check mode.
-o
Specifies that file ownership is not to be preserved.
-s
Specifies that the effective UID is to be set to 0 before copytree is started.
<sourcedir>
The path name for the source directory where the copy begins. The path name must be used, not the file system name.
<targetdir>
The path name for the target directory. This directory must exist and must be empty. The permissions and other attributes of the target directory are not modified to be the same as the source directory. If <targetdir> is not specified, copytree runs in a mode to check the source file tree.

Exit values

0
Successful completion
>0
An error occurred

Any other value means that there were errors.

Related information

pax