0

Can you help me with that script? I would like to transfer files to my bucket on S3 AWS.

My code:

$cmd = "s3cmd -v -c /root/.s3cfg put /var/project_db_" . $date . ".sql.xz s3://bucket600";

My second code - What I'm using. And doesn't work.

$cmd = "s3cmd expire -v -c /root/.s3cfg put /var/project_db_" . $date . ".sql.xz --expiry-day=90 s3://bucket600";

Thank you for your help

Marcin
  • 215,873
  • 14
  • 235
  • 294

2 Answers2

2

I searched Google for s3cmd expire and the first result took me to this page which says this:

Advanced features

Object Expiration with s3cmd

You can set an object expiration policy on a bucket, so that objects older than a particular age will be deleted automatically. The expiration policy can have a prefix, an effective date, and number of days to expire after.

s3cmd v2.0.0 can be used to set or review the policy:

 [lxplus-cloud]$ s3cmd expire s3://dvanders-test --expiry-days 2
 Bucket 's3://dvanders-test/': expiration configuration is set.

 [lxplus-cloud]$ s3cmd getlifecycle s3://dvanders-test
 <?xml version="1.0" ?>
 <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
  <Rule>
   <ID>ir0smpb610i0lthrl31jpxzegwximbcz3rrgb1he2yfxgudm</ID>
   <Prefix/>
   <Status>Enabled</Status>
   <Expiration>
    <Days>2</Days>
   </Expiration>
  </Rule>
 </LifecycleConfiguration>

Additional s3cmd expire options include:

 --expiry-date=EXPIRY_DATE
         Indicates when the expiration rule takes effect. (only
         for [expire] command)
 --expiry-days=EXPIRY_DAYS
         Indicates the number of days after object creation the
         expiration rule takes effect. (only for [expire] command)
 --expiry-prefix=EXPIRY_PREFIX
         Identifying one or more objects with the prefix to
         which the expiration rule applies. (only for [expire]
         command)

So you use the --expiry-date or --expiry-days command line option to do what you want.

(This question has nothing at all to do with Perl.)

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
0

when you have to place any file into the s3 bucket. You need to provide the location inside the s3 where you would want the file to be stored. If the specified folder(abstract) does not exist then it will be created.

In case you want to put the file to / (root) of the s3 then the destination would be set as "s3://bucket600/" (notice the slash at the end).

Muhammad Hasan
  • 140
  • 1
  • 9