github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/cmd/settier/settier.go (about) 1 // Package settier provides the settier command. 2 package settier 3 4 import ( 5 "context" 6 "fmt" 7 8 "github.com/rclone/rclone/cmd" 9 "github.com/rclone/rclone/fs/operations" 10 "github.com/spf13/cobra" 11 ) 12 13 func init() { 14 cmd.Root.AddCommand(commandDefinition) 15 } 16 17 var commandDefinition = &cobra.Command{ 18 Use: "settier tier remote:path", 19 Short: `Changes storage class/tier of objects in remote.`, 20 Long: ` 21 rclone settier changes storage tier or class at remote if supported. 22 Few cloud storage services provides different storage classes on objects, 23 for example AWS S3 and Glacier, Azure Blob storage - Hot, Cool and Archive, 24 Google Cloud Storage, Regional Storage, Nearline, Coldline etc. 25 26 Note that, certain tier changes make objects not available to access immediately. 27 For example tiering to archive in azure blob storage makes objects in frozen state, 28 user can restore by setting tier to Hot/Cool, similarly S3 to Glacier makes object 29 inaccessible.true 30 31 You can use it to tier single object 32 33 rclone settier Cool remote:path/file 34 35 Or use rclone filters to set tier on only specific files 36 37 rclone --include "*.txt" settier Hot remote:path/dir 38 39 Or just provide remote directory and all files in directory will be tiered 40 41 rclone settier tier remote:path/dir 42 `, 43 Annotations: map[string]string{ 44 "versionIntroduced": "v1.44", 45 }, 46 Run: func(command *cobra.Command, args []string) { 47 cmd.CheckArgs(2, 2, command, args) 48 tier := args[0] 49 input := args[1:] 50 fsrc := cmd.NewFsSrc(input) 51 cmd.Run(false, false, command, func() error { 52 isSupported := fsrc.Features().SetTier 53 if !isSupported { 54 return fmt.Errorf("remote %s does not support settier", fsrc.Name()) 55 } 56 57 return operations.SetTier(context.Background(), fsrc, tier) 58 }) 59 }, 60 }