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