Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

Chapter 22. Copying files to or from a container


22.1. Overview

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.

22.2. Basic Usage

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

22.3. Requirements

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.

Note

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.

Note

In Windows, the cwRsync client should be installed and added to the PATH for use with oc rsync

22.4. Specifying the copy source

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.

22.5. Specifying the copy destination

The destination argument of the oc rsync command must point to a directory. If the directory does not exist, but rsync is used for copy, the directory is created for you.

22.6. Deleting files at the destination

The --delete flag may be used to delete any files in the remote directory that are not in the local directory.

Red Hat logoGithubRedditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

© 2024 Red Hat, Inc.