aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorflouthoc <flouthoc.git@gmail.com>2021-08-20 14:22:54 +0530
committerflouthoc <flouthoc.git@gmail.com>2021-08-23 20:42:41 +0530
commitedddfe8c4f7761b12dc64ea4aa0a83b755aa124f (patch)
tree4eb4323903b3aec46fd5da3dd7152c24d88045d0 /utils
parent30b036c5d394bb523fa13074b1731ad4b6259693 (diff)
downloadpodman-edddfe8c4f7761b12dc64ea4aa0a83b755aa124f.tar.gz
podman-edddfe8c4f7761b12dc64ea4aa0a83b755aa124f.tar.bz2
podman-edddfe8c4f7761b12dc64ea4aa0a83b755aa124f.zip
volumes: Add support for exporting volumes to external tar
Adds support for transferring data between systems and backing up systems. Use cases: recover from disasters or move data between machines. Signed-off-by: flouthoc <flouthoc.git@gmail.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/utils.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/utils/utils.go b/utils/utils.go
index a2268a30b..2e415130e 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -107,6 +107,16 @@ func UntarToFileSystem(dest string, tarball *os.File, options *archive.TarOption
return archive.Untar(tarball, dest, options)
}
+// Creates a new tar file and wrties bytes from io.ReadCloser
+func CreateTarFromSrc(source string, dest string) error {
+ file, err := os.Create(dest)
+ if err != nil {
+ return errors.Wrapf(err, "Could not create tarball file '%s'", dest)
+ }
+ defer file.Close()
+ return TarToFilesystem(source, file)
+}
+
// TarToFilesystem creates a tarball from source and writes to an os.file
// provided
func TarToFilesystem(source string, tarball *os.File) error {