Class: RubyS3Cmd::S3Cmd

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-s3cmd/s3cmd.rb

Overview

class RubyS3CMD::S3Cmd.new( array, str, array)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#acl_privateObject

Store objects with default ACL allowing access for you only.



176
177
178
# File 'lib/ruby-s3cmd/s3cmd.rb', line 176

def acl_private
  @acl_private
end

#acl_publicObject

Store objects with permissions allowing read for anyone. See s3tools.org/s3cmd-public for details and hints for storing publicly accessible files.



171
172
173
# File 'lib/ruby-s3cmd/s3cmd.rb', line 171

def acl_public
  @acl_public
end

#add_headerObject

Add a given HTTP header to the upload request. Can be used multiple times with different header names. For instance set ‘Expires’ or ‘Cache-Control’ headers (or both) using this options if you like.



165
166
167
# File 'lib/ruby-s3cmd/s3cmd.rb', line 165

def add_header
  @add_header
end

#bucket_locationObject

Specify datacentre where to create the bucket. Possible values are US (default) or EU.



32
33
34
# File 'lib/ruby-s3cmd/s3cmd.rb', line 32

def bucket_location
  @bucket_location
end

#cf_add_cnameObject

Add given CNAME to a CloudFront distribution (only for cfcreate and cfmodify commands)



208
209
210
# File 'lib/ruby-s3cmd/s3cmd.rb', line 208

def cf_add_cname
  @cf_add_cname
end

#cf_commentObject

Set COMMENT for a given CloudFront distribution (only for cfcreate and cfmodify commands)



218
219
220
# File 'lib/ruby-s3cmd/s3cmd.rb', line 218

def cf_comment
  @cf_comment
end

#cf_remove_cnameObject

Remove given CNAME from a CloudFront distribution (only for cfmodify command)



213
214
215
# File 'lib/ruby-s3cmd/s3cmd.rb', line 213

def cf_remove_cname
  @cf_remove_cname
end

#configObject

Config file name. Defaults to $HOME/.s3cfg



73
74
75
# File 'lib/ruby-s3cmd/s3cmd.rb', line 73

def config
  @config
end

#continueObject

Continue getting a partially downloaded file (only for get command). This comes handy once download of a large file, say an ISO image, from a S3 bucket fails and a partially downloaded file is left on the disk. Unfortunately put command doesn’t support restarting of failed upload due to Amazon S3 limitations.



142
143
144
# File 'lib/ruby-s3cmd/s3cmd.rb', line 142

def continue
  @continue
end

#debugObject

Enable debug output.



64
65
66
# File 'lib/ruby-s3cmd/s3cmd.rb', line 64

def debug
  @debug
end

#delete_removedObject

Delete remote objects with no corresponding local file when syncing to S3 or delete local files with no corresponding object in S3 when syncing from S3.



89
90
91
# File 'lib/ruby-s3cmd/s3cmd.rb', line 89

def delete_removed
  @delete_removed
end

#disableObject

Enable given CloudFront distribution (only for cfmodify command)



203
204
205
# File 'lib/ruby-s3cmd/s3cmd.rb', line 203

def disable
  @disable
end

#dry_runObject

Only show what should be uploaded or downloaded but don’t actually do it. May still perform S3 requests to get bucket listings and other in formation though.



83
84
85
# File 'lib/ruby-s3cmd/s3cmd.rb', line 83

def dry_run
  @dry_run
end

#enableObject

Enable given CloudFront distribution (only for cfmodify command)



198
199
200
# File 'lib/ruby-s3cmd/s3cmd.rb', line 198

def enable
  @enable
end

#encodingObject

Override autodetected terminal and filesystem encoding (character set).



54
55
56
# File 'lib/ruby-s3cmd/s3cmd.rb', line 54

def encoding
  @encoding
end

#encryptObject

Use GPG encryption to protect stored objects from unauthorized access. See s3tools.org/s3cmd- public for details about encryption.



182
183
184
# File 'lib/ruby-s3cmd/s3cmd.rb', line 182

def encrypt
  @encrypt
end

#excludeObject

Exclude files matching GLOB (a.k.a. shell-style wildcard) from sync. See FILE TRANSFERS section and s3tools.org/s3cmd-sync for more information.



110
111
112
# File 'lib/ruby-s3cmd/s3cmd.rb', line 110

def exclude
  @exclude
end

#exclude_fromObject

Same as –exclude but reads GLOBs from the given FILE instead of expecting them on the command line.



115
116
117
# File 'lib/ruby-s3cmd/s3cmd.rb', line 115

def exclude_from
  @exclude_from
end

#forceObject

Force overwrite and other dangerous operations. Can be used to remove a non-empty buckets with s3cmd rb –force s3://bkt



27
28
29
# File 'lib/ruby-s3cmd/s3cmd.rb', line 27

def force
  @force
end

#guess_mime_typeObject

Guess MIME‐type of files by their extension. Falls back to default MIME‐Type as specified by –mime-type option



158
159
160
# File 'lib/ruby-s3cmd/s3cmd.rb', line 158

def guess_mime_type
  @guess_mime_type
end

#human_readable_sizesObject

Print sizes in human readable form.



37
38
39
# File 'lib/ruby-s3cmd/s3cmd.rb', line 37

def human_readable_sizes
  @human_readable_sizes
end

#includeObject

Filenames and paths matching GLOB or REGEXP will be included even if previously excluded by one of –®exclude(-from) patterns



131
132
133
# File 'lib/ruby-s3cmd/s3cmd.rb', line 131

def include
  @include
end

#include_fromObject

FILE



132
133
134
# File 'lib/ruby-s3cmd/s3cmd.rb', line 132

def include_from
  @include_from
end

#list_md5Object

Include MD5 sums in bucket listings (only for ls command).



42
43
44
# File 'lib/ruby-s3cmd/s3cmd.rb', line 42

def list_md5
  @list_md5
end

#mime_typeObject

Default MIME-type to be set for objects stored.



152
153
154
# File 'lib/ruby-s3cmd/s3cmd.rb', line 152

def mime_type
  @mime_type
end

#no_delete_removedObject

Don’t delete remote objects. Default for sync command.



94
95
96
# File 'lib/ruby-s3cmd/s3cmd.rb', line 94

def no_delete_removed
  @no_delete_removed
end

#no_encryptObject

Don’t encrypt files.



187
188
189
# File 'lib/ruby-s3cmd/s3cmd.rb', line 187

def no_encrypt
  @no_encrypt
end

#no_preserveObject

Don’t store filesystem attributes with uploaded files.



104
105
106
# File 'lib/ruby-s3cmd/s3cmd.rb', line 104

def no_preserve
  @no_preserve
end

#no_progressObject

Display or don’t display progress meter. When running on TTY (e.g. console or xterm) the default is to display progress meter. If not on TTY (e.g. output is redirected somewhere or running from cron) the default is to not display progress meter.



49
50
51
# File 'lib/ruby-s3cmd/s3cmd.rb', line 49

def no_progress
  @no_progress
end

#path_to_s3cmdObject

Sets the executable path, otherwise the environment path will be used.



223
224
225
# File 'lib/ruby-s3cmd/s3cmd.rb', line 223

def path_to_s3cmd
  @path_to_s3cmd
end

#preserveObject

Preserve filesystem attributes (mode, ownership, timestamps). Default for sync command.



99
100
101
# File 'lib/ruby-s3cmd/s3cmd.rb', line 99

def preserve
  @preserve
end

#progressObject

Display or don’t display progress meter. When running on TTY (e.g. console or xterm) the default is to display progress meter. If not on TTY (e.g. output is redirected somewhere or running from cron) the default is to not display progress meter.



49
50
51
# File 'lib/ruby-s3cmd/s3cmd.rb', line 49

def progress
  @progress
end

#recursiveObject

Recursive upload, download or removal. When used with del it can remove all the files in a bucket.



21
22
23
# File 'lib/ruby-s3cmd/s3cmd.rb', line 21

def recursive
  @recursive
end

#rexcludeObject

Same as –exclude but works with REGEXPs (Regular expressions).



120
121
122
# File 'lib/ruby-s3cmd/s3cmd.rb', line 120

def rexclude
  @rexclude
end

#rexclude_fromObject

Same as –exclude-from but works with REGEXPs.



125
126
127
# File 'lib/ruby-s3cmd/s3cmd.rb', line 125

def rexclude_from
  @rexclude_from
end

#rincludeObject

REGEXP



133
134
135
# File 'lib/ruby-s3cmd/s3cmd.rb', line 133

def rinclude
  @rinclude
end

#rinclude_fromObject

FILE



134
135
136
# File 'lib/ruby-s3cmd/s3cmd.rb', line 134

def rinclude_from
  @rinclude_from
end

#skip_existingObject

Skip over files that exist at the destination (only for get and sync commands).



147
148
149
# File 'lib/ruby-s3cmd/s3cmd.rb', line 147

def skip_existing
  @skip_existing
end

#verboseObject

Enable verbose output.



59
60
61
# File 'lib/ruby-s3cmd/s3cmd.rb', line 59

def verbose
  @verbose
end

Instance Method Details

#cfcreate(bucket) ⇒ Object

Create CloudFront distribution point



337
338
339
# File 'lib/ruby-s3cmd/s3cmd.rb', line 337

def cfcreate(bucket) # s3://BUCKET
  send_command "cfcreate", bucket
end

#cfdelete(dist_id) ⇒ Object

Delete CloudFront distribution point



342
343
344
# File 'lib/ruby-s3cmd/s3cmd.rb', line 342

def cfdelete(dist_id) # cf://DIST_ID
  send_command "cfdelete", dist_id
end

#cfinfo(dist_id) ⇒ Object

Display CloudFront distribution point parameters



332
333
334
# File 'lib/ruby-s3cmd/s3cmd.rb', line 332

def cfinfo(dist_id) # [cf://DIST_ID]
  send_command "cfinfo", dist_id
end

#cflistObject

List CloudFront distribution points



327
328
329
# File 'lib/ruby-s3cmd/s3cmd.rb', line 327

def cflist
  send_command "cflist"
end

#cfmodify(dist_id) ⇒ Object

Change CloudFront distribution point parameters



347
348
349
# File 'lib/ruby-s3cmd/s3cmd.rb', line 347

def cfmodify(dist_id) # cf://DIST_ID
  send_command "cfmodify", dist_id
end

#configureObject

Invoke interactive (re)configuration tool. Don’t worry, you won’t lose your settings on subsequent runs.



243
244
245
# File 'lib/ruby-s3cmd/s3cmd.rb', line 243

def configure
 send_command "--configure"
end

#cp(src_bucket, dest_bucket) ⇒ Object

Make a copy of a file (cp) or move a file (mv). Destination can be in the same bucket with a dif‐ ferent name or in another bucket with the same or different name. Adding –acl-public will make the destination object publicly accessible (see below).



298
299
300
# File 'lib/ruby-s3cmd/s3cmd.rb', line 298

def cp(src_bucket, dest_bucket) # s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]
  send_command "cp", src_bucket, dest_bucket
end

#del(bucket) ⇒ Object

Delete file from bucket



285
286
287
# File 'lib/ruby-s3cmd/s3cmd.rb', line 285

def del(bucket) # s3://BUCKET/OBJECT
  send_command "del"
end

#du(bucket) ⇒ Object

Disk usage - amount of data stored in S3



320
321
322
# File 'lib/ruby-s3cmd/s3cmd.rb', line 320

def du(bucket) # [s3://BUCKET[/PREFIX]]
  send_command "du", bucket
end

#dump_configObject

Dump current configuration after parsing config files and command line options and exit.



250
251
252
# File 'lib/ruby-s3cmd/s3cmd.rb', line 250

def dump_config
   send_command "--dump-config"
end

#get(bucket, local_file = nil) ⇒ Object

Get file from bucket (i.e. download from S3)



280
281
282
# File 'lib/ruby-s3cmd/s3cmd.rb', line 280

def get(bucket, local_file=nil) # s3://BUCKET/OBJECT LOCAL_FILE
  send_command "get", bucket, local_file
end

#helpObject

Show the help message and exit



228
229
230
# File 'lib/ruby-s3cmd/s3cmd.rb', line 228

def help
 send_command "--help"
end

#info(bucket) ⇒ Object

Get various information about a Bucket or Object



315
316
317
# File 'lib/ruby-s3cmd/s3cmd.rb', line 315

def info(bucket) # s3://BUCKET[/OBJECT]
  send_command "info", bucket
end

#laObject

List all object in all buckets



270
271
272
# File 'lib/ruby-s3cmd/s3cmd.rb', line 270

def la
  send_command "la"
end

#ls(bucket) ⇒ Object

List objects or buckets



265
266
267
# File 'lib/ruby-s3cmd/s3cmd.rb', line 265

def ls(bucket) # s3://BUCKET[/PREFIX]]
  send_command "ls", bucket
end

#mb(bucket) ⇒ Object

Make bucket



255
256
257
# File 'lib/ruby-s3cmd/s3cmd.rb', line 255

def mb(bucket) # s3://BUCKET
  send_command "mb", bucket
end

#mv(src_bucket, dest_bucket) ⇒ Object

Make a copy of a file (cp) or move a file (mv). Destination can be in the same bucket with a dif‐ ferent name or in another bucket with the same or different name. Adding –acl-public will make the destination object publicly accessible (see below).



305
306
307
# File 'lib/ruby-s3cmd/s3cmd.rb', line 305

def mv(src_bucket, dest_bucket) # s3://BUCKET1/OBJECT1 s3://BUCKET2[/OBJECT2]
  send_command "mv", src_bucket, dest_bucket
end

#put(files, bucket) ⇒ Object

Put file into bucket (i.e. upload to S3)



275
276
277
# File 'lib/ruby-s3cmd/s3cmd.rb', line 275

def put(files, bucket) # FILE [FILE...] s3://BUCKET[/PREFIX]
  send_command "put", files, bucket
end

#rb(bucket) ⇒ Object

Remove bucket



260
261
262
# File 'lib/ruby-s3cmd/s3cmd.rb', line 260

def rb(bucket) # s3://BUCKET
  send_command "rb", bucket
end

#setacl(bucket) ⇒ Object

Modify Access control list for Bucket or Files. Use with –acl-public or –acl-private



310
311
312
# File 'lib/ruby-s3cmd/s3cmd.rb', line 310

def setacl(bucket) # s3://BUCKET[/OBJECT]
  send_command "setacl", bucket
end

#show_configObject



351
352
353
# File 'lib/ruby-s3cmd/s3cmd.rb', line 351

def show_config
  option_string
end

#sync(src_object, dest_object = nil) ⇒ Object

Backup a directory tree to S3 Restore a tree from S3 to local directory



291
292
293
# File 'lib/ruby-s3cmd/s3cmd.rb', line 291

def sync(src_object, dest_object=nil) # LOCAL_DIR s3://BUCKET[/PREFIX] or s3://BUCKET[/PREFIX] LOCAL_DIR
  send_command "sync", src_object, dest_object
end

#versionObject

Show s3cmd version and exit.



235
236
237
# File 'lib/ruby-s3cmd/s3cmd.rb', line 235

def version
 send_command "--version"
end