Class: RubyS3Cmd::S3Cmd
- Inherits:
-
Object
- Object
- RubyS3Cmd::S3Cmd
- Defined in:
- lib/ruby-s3cmd/s3cmd.rb
Overview
class RubyS3CMD::S3Cmd.new( array, str, array)
Instance Attribute Summary collapse
-
#acl_private ⇒ Object
Store objects with default ACL allowing access for you only.
-
#acl_public ⇒ Object
Store objects with permissions allowing read for anyone.
-
#add_header ⇒ Object
Add a given HTTP header to the upload request.
-
#bucket_location ⇒ Object
Specify datacentre where to create the bucket.
-
#cf_add_cname ⇒ Object
Add given CNAME to a CloudFront distribution (only for cfcreate and cfmodify commands).
-
#cf_comment ⇒ Object
Set COMMENT for a given CloudFront distribution (only for cfcreate and cfmodify commands).
-
#cf_remove_cname ⇒ Object
Remove given CNAME from a CloudFront distribution (only for cfmodify command).
-
#config ⇒ Object
Config file name.
-
#continue ⇒ Object
Continue getting a partially downloaded file (only for get command).
-
#debug ⇒ Object
Enable debug output.
-
#delete_removed ⇒ Object
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.
-
#disable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command).
-
#dry_run ⇒ Object
Only show what should be uploaded or downloaded but don’t actually do it.
-
#enable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command).
-
#encoding ⇒ Object
Override autodetected terminal and filesystem encoding (character set).
-
#encrypt ⇒ Object
Use GPG encryption to protect stored objects from unauthorized access.
-
#exclude ⇒ Object
Exclude files matching GLOB (a.k.a. shell-style wildcard) from sync.
-
#exclude_from ⇒ Object
Same as –exclude but reads GLOBs from the given FILE instead of expecting them on the command line.
-
#force ⇒ Object
Force overwrite and other dangerous operations.
-
#guess_mime_type ⇒ Object
Guess MIME‐type of files by their extension.
-
#human_readable_sizes ⇒ Object
Print sizes in human readable form.
-
#include ⇒ Object
Filenames and paths matching GLOB or REGEXP will be included even if previously excluded by one of –®exclude(-from) patterns.
-
#include_from ⇒ Object
FILE.
-
#list_md5 ⇒ Object
Include MD5 sums in bucket listings (only for ls command).
-
#mime_type ⇒ Object
Default MIME-type to be set for objects stored.
-
#no_delete_removed ⇒ Object
Don’t delete remote objects.
-
#no_encrypt ⇒ Object
Don’t encrypt files.
-
#no_preserve ⇒ Object
Don’t store filesystem attributes with uploaded files.
-
#no_progress ⇒ Object
Display or don’t display progress meter.
-
#path_to_s3cmd ⇒ Object
Sets the executable path, otherwise the environment path will be used.
-
#preserve ⇒ Object
Preserve filesystem attributes (mode, ownership, timestamps).
-
#progress ⇒ Object
Display or don’t display progress meter.
-
#recursive ⇒ Object
Recursive upload, download or removal.
-
#rexclude ⇒ Object
Same as –exclude but works with REGEXPs (Regular expressions).
-
#rexclude_from ⇒ Object
Same as –exclude-from but works with REGEXPs.
-
#rinclude ⇒ Object
REGEXP.
-
#rinclude_from ⇒ Object
FILE.
-
#skip_existing ⇒ Object
Skip over files that exist at the destination (only for get and sync commands).
-
#verbose ⇒ Object
Enable verbose output.
Instance Method Summary collapse
-
#cfcreate(bucket) ⇒ Object
Create CloudFront distribution point.
-
#cfdelete(dist_id) ⇒ Object
Delete CloudFront distribution point.
-
#cfinfo(dist_id) ⇒ Object
Display CloudFront distribution point parameters.
-
#cflist ⇒ Object
List CloudFront distribution points.
-
#cfmodify(dist_id) ⇒ Object
Change CloudFront distribution point parameters.
-
#configure ⇒ Object
Invoke interactive (re)configuration tool.
-
#cp(src_bucket, dest_bucket) ⇒ Object
Make a copy of a file (cp) or move a file (mv).
-
#del(bucket) ⇒ Object
Delete file from bucket.
-
#du(bucket) ⇒ Object
Disk usage - amount of data stored in S3.
-
#dump_config ⇒ Object
Dump current configuration after parsing config files and command line options and exit.
-
#get(bucket, local_file = nil) ⇒ Object
Get file from bucket (i.e. download from S3).
-
#help ⇒ Object
Show the help message and exit.
-
#info(bucket) ⇒ Object
Get various information about a Bucket or Object.
-
#la ⇒ Object
List all object in all buckets.
-
#ls(bucket) ⇒ Object
List objects or buckets.
-
#mb(bucket) ⇒ Object
Make bucket.
-
#mv(src_bucket, dest_bucket) ⇒ Object
Make a copy of a file (cp) or move a file (mv).
-
#put(files, bucket) ⇒ Object
Put file into bucket (i.e. upload to S3).
-
#rb(bucket) ⇒ Object
Remove bucket.
-
#setacl(bucket) ⇒ Object
Modify Access control list for Bucket or Files.
- #show_config ⇒ Object
-
#sync(src_object, dest_object = nil) ⇒ Object
Backup a directory tree to S3 Restore a tree from S3 to local directory.
-
#version ⇒ Object
Show s3cmd version and exit.
Instance Attribute Details
#acl_private ⇒ Object
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_public ⇒ Object
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_header ⇒ Object
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_location ⇒ Object
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_cname ⇒ Object
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_comment ⇒ Object
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_cname ⇒ Object
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 |
#config ⇒ Object
Config file name. Defaults to $HOME/.s3cfg
73 74 75 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 73 def config @config end |
#continue ⇒ Object
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 |
#debug ⇒ Object
Enable debug output.
64 65 66 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 64 def debug @debug end |
#delete_removed ⇒ Object
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 |
#disable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command)
203 204 205 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 203 def disable @disable end |
#dry_run ⇒ Object
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 |
#enable ⇒ Object
Enable given CloudFront distribution (only for cfmodify command)
198 199 200 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 198 def enable @enable end |
#encoding ⇒ Object
Override autodetected terminal and filesystem encoding (character set).
54 55 56 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 54 def encoding @encoding end |
#encrypt ⇒ Object
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 |
#exclude ⇒ Object
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_from ⇒ Object
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 |
#force ⇒ Object
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_type ⇒ Object
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_sizes ⇒ Object
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 |
#include ⇒ Object
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_from ⇒ Object
FILE
132 133 134 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 132 def include_from @include_from end |
#list_md5 ⇒ Object
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_type ⇒ Object
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_removed ⇒ Object
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_encrypt ⇒ Object
Don’t encrypt files.
187 188 189 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 187 def no_encrypt @no_encrypt end |
#no_preserve ⇒ Object
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_progress ⇒ Object
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_s3cmd ⇒ Object
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 |
#preserve ⇒ Object
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 |
#progress ⇒ Object
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 |
#recursive ⇒ Object
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 |
#rexclude ⇒ Object
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_from ⇒ Object
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 |
#rinclude ⇒ Object
REGEXP
133 134 135 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 133 def rinclude @rinclude end |
#rinclude_from ⇒ Object
FILE
134 135 136 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 134 def rinclude_from @rinclude_from end |
#skip_existing ⇒ Object
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 |
#verbose ⇒ Object
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 |
#cflist ⇒ Object
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 |
#configure ⇒ Object
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_config ⇒ Object
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 |
#help ⇒ Object
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 |
#la ⇒ Object
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_config ⇒ Object
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 |
#version ⇒ Object
Show s3cmd version and exit.
235 236 237 |
# File 'lib/ruby-s3cmd/s3cmd.rb', line 235 def version send_command "--version" end |