$ oc rsync <source> <destination> [-c <container>]
You can use the cli to copy local files to or from a remote directory in a container.
You can use the cli to copy local files to or from a remote directory in a container. This is a useful tool for copying database archives to and from your pods for backup and restore purposes. It can also be used to copy source code changes into a running pod for development debugging, when the running pod supports hot reload of source files.
Support for copying local files to or from a container is built into the cli:
$ oc rsync <source> <destination> [-c <container>]
For example:
# Copy local directory to a pod directory $ oc rsync /home/user/source devpod1234:/src # Copy pod directory to a local directory $ oc rsync devpod1234:/src /home/user/source
The oc rsync
command uses the local rsync
command if present on the client’s machine. This requires
that the remote container also have the rsync
command. If rsync
is not found locally or in the remote
container, then a tar archive will be created locally and sent to the container where tar
will be used to
extract the files. If tar
is not available in the remote container, then the copy will fail.
The tar copy method does not provide the same functionality as rsync. For example, rsync will create the destination directory if it doesn’t exist and will only send files that are different between the source and the destination. |
In Windows, the cwRsync client should be installed and added to the PATH for use with |
The source argument of the oc rsync
command must point to either a local directory or a pod directory. Individual
files are not currently supported. When specifying a pod directory the directory name must be prefixed with the pod
name: <pod name>:<dir>
. Just as with UNIX rsync, if the directory name ends in a path separator ('/'), only the
contents of the directory are copied to the destination. Otherwise, the directory itself is copied to the destination
with all its contents.