create

package
v1.74.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package create implements 'rclone archive create'.

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "create [flags] <source> [<destination>]",
	Short: `Archive source file(s) to destination.`,

	Long: strings.ReplaceAll(`
Creates an archive from the files in source:path and saves the archive to
dest:path. If dest:path is missing, it will write to the console.

The valid formats for the !--format! flag are listed below. If
!--format! is not set rclone will guess it from the extension of dest:path.

| Format | Extensions |
|:-------|:-----------|
| zip    | .zip       |
| tar    | .tar       |
| tar.gz | .tar.gz, .tgz, .taz |
| tar.bz2| .tar.bz2, .tb2, .tbz, .tbz2, .tz2 |
| tar.lz | .tar.lz    |
| tar.lz4| .tar.lz4   |
| tar.xz | .tar.xz, .txz |
| tar.zst| .tar.zst, .tzst |
| tar.br | .tar.br    |
| tar.sz | .tar.sz    |
| tar.mz | .tar.mz    |

The !--prefix! and !--full-path! flags control the prefix for the files
in the archive.

If the flag !--full-path! is set then the files will have the full source
path as the prefix.

If the flag !--prefix=<value>! is set then the files will have
!<value>! as prefix. It's possible to create invalid file names with
!--prefix=<value>! so use with caution. Flag !--prefix! has
priority over !--full-path!.

Given a directory !/sourcedir! with the following:

    file1.txt
    dir1/file2.txt

Running the command !rclone archive create /sourcedir /dest.tar.gz!
will make an archive with the contents:

    file1.txt
    dir1/
    dir1/file2.txt

Running the command !rclone archive create --full-path /sourcedir /dest.tar.gz!
will make an archive with the contents:

    sourcedir/file1.txt
    sourcedir/dir1/
    sourcedir/dir1/file2.txt

Running the command !rclone archive create --prefix=my_new_path /sourcedir /dest.tar.gz!
will make an archive with the contents:

    my_new_path/file1.txt
    my_new_path/dir1/
    my_new_path/dir1/file2.txt
`, "!", "`"),
	Annotations: map[string]string{
		"versionIntroduced": "v1.72",
	},
	RunE: func(command *cobra.Command, args []string) error {
		var src, dst fs.Fs
		var dstFile string
		if len(args) == 1 {
			src = cmd.NewFsSrc(args)
		} else if len(args) == 2 {
			src = cmd.NewFsSrc(args)
			dst, dstFile = cmd.NewFsDstFile(args[1:2])
		} else {
			cmd.CheckArgs(1, 2, command, args)
		}
		cmd.Run(false, false, command, func() error {
			fmt.Printf("dst=%v, dstFile=%q, src=%v, format=%q, prefix=%q\n", dst, dstFile, src, format, prefix)
			if prefix != "" {
				return ArchiveCreate(context.Background(), dst, dstFile, src, format, prefix)
			} else if fullPath {
				return ArchiveCreate(context.Background(), dst, dstFile, src, format, src.Root())
			}
			return ArchiveCreate(context.Background(), dst, dstFile, src, format, "")
		})
		return nil
	},
}

Command - create

Functions

func ArchiveCreate

func ArchiveCreate(ctx context.Context, dst fs.Fs, dstFile string, src fs.Fs, format string, prefix string) error

ArchiveCreate - compresses/archive source to destination

func CheckValidDestination

func CheckValidDestination(ctx context.Context, dst fs.Fs, dstFile string) error

CheckValidDestination - takes (dst, dstFile) and checks it is valid

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL