"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
cmd and fs: Added new command settier which performs storage tier changes on supported remotes
sandeepkru7accd30da8d3
diff --git a/cmd/all/all.go b/cmd/all/all.goindex da0bd6009..dcb7e8353 100644--- a/cmd/all/all.go+++ b/cmd/all/all.go@@ -47,6 +47,7 @@ import (_ "github.com/ncw/rclone/cmd/rmdir"_ "github.com/ncw/rclone/cmd/rmdirs"_ "github.com/ncw/rclone/cmd/serve"+ _ "github.com/ncw/rclone/cmd/settier"_ "github.com/ncw/rclone/cmd/sha1sum"_ "github.com/ncw/rclone/cmd/size"_ "github.com/ncw/rclone/cmd/sync"diff --git a/cmd/settier/settier.go b/cmd/settier/settier.gonew file mode 100644index 000000000..2faa7b643--- /dev/null+++ b/cmd/settier/settier.go@@ -0,0 +1,54 @@+package settier++import (+ "github.com/ncw/rclone/cmd"+ "github.com/ncw/rclone/fs/operations"+ "github.com/pkg/errors"+ "github.com/spf13/cobra"+)++func init() {+ cmd.Root.AddCommand(commandDefintion)+}++var commandDefintion = &cobra.Command{+ Use: "settier tier remote:path",+ Short: `Changes storage class/tier of objects in remote.`,+ Long: `+rclone settier changes storage tier or class at remote if supported.+Few cloud storage services provides different storage classes on objects,+for example AWS S3 and Glacier, Azure Blob storage - Hot, Cool and Archive,+Google Cloud Storage, Regional Storage, Nearline, Coldline etc.++Note that, certain tier chages make objects not available to access immediately.+For example tiering to archive in azure blob storage makes objects in frozen state,+user can restore by setting tier to Hot/Cool, similarly S3 to Glacier makes object+inaccessible.true++You can use it to tier single object++ rclone settier Cool remote:path/file++Or use rclone filters to set tier on only specific files++ rclone --include "*.txt" settier Hot remote:path/dir++Or just provide remote directory and all files in directory will be tiered++ rclone settier tier remote:path/dir+`,+ Run: func(command *cobra.Command, args []string) {+ cmd.CheckArgs(2, 2, command, args)+ tier := args[0]+ input := args[1:]+ fsrc := cmd.NewFsSrc(input)+ cmd.Run(false, false, command, func() error {+ isSupported := fsrc.Features().SetTier+ if !isSupported {+ return errors.Errorf("Remote %s does not support settier", fsrc.Name())+ }++ return operations.SetTier(fsrc, tier)+ })+ },+}diff --git a/fs/operations/operations.go b/fs/operations/operations.goindex a3ace8b02..4ef8f4b78 100644--- a/fs/operations/operations.go+++ b/fs/operations/operations.go@@ -1407,6 +1407,21 @@ func CopyFile(fdst fs.Fs, fsrc fs.Fs, dstFileName string, srcFileName string) (ereturn moveOrCopyFile(fdst, fsrc, dstFileName, srcFileName, true)}+// SetTier changes tier of object in remote+func SetTier(fsrc fs.Fs, tier string) error {+ return ListFn(fsrc, func(o fs.Object) {+ objImpl, ok := o.(fs.SetTierer)+ if !ok {+ fs.Errorf(fsrc, "Remote object does not implement SetTier")+ return+ }+ err := objImpl.SetTier(tier)+ if err != nil {+ fs.Errorf(fsrc, "Failed to do SetTier, %v", err)+ }+ })+}+// ListFormat defines files information print formattype ListFormat struct {separator string