Backup Amazon S3 with PHP


Hits: 2478  

This is the source code to backup/download Amazon S3 Bucket’s multimedia files to other server by PHP…

here $bucketurl is XML url of Amazon S3 bucket with full ACL.
$folder is path of the server where S3 files to store.

This script will download all files in Amazon bucket to other server

Php-Code:
 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 

<?php

/* url for Amazon Bucket */

$bucketurl "http://BUCKETNAME.s3.amazonaws.com/";

$xml file_get_contents($bucketurl);

/* folder name for server */

$folder "/var/www/html/BUCKETNAME/";

$content getTag'Key'$xml );

foreach($content as $file)

{

exec"wget -O ".$folder.$file." ".$bucketurl.$file );

}

/* function to get node from Amazon Bucket XML */

function getTag$tag$xml )

{

$tag preg_quote($tag);

preg_match_all('{<'.$tag.'[^>]*>(.*?)</'.$tag.'>}'$xml$matchesPREG_PATTERN_ORDER);

return 
$matches[1];

}

?>

Published by

Sandeep Verma

I’m an Entrepreneur. I’m proud to work as Blogger, LAMP Programmer, Linux Admin, Web Consultant, Cloud Manager, Apps Developer, Searcher. Concentrate > Observe > Imagine > Launch

25 thoughts on “Backup Amazon S3 with PHP”

  1. Hello there! I could have sworn I’ve been to this website before but
    after browsing through some of the post I realized it’s new to me.
    Nonetheless, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!

  2. Good way of describing, and nice piece of writing to obtain facts regarding my presentation topic,
    which i am going to convey in institution of higher education.

  3. This is really interesting, You’re a very skilled blogger.
    I’ve joined your feed and look forward to seeking more of your magnificent post.

    Also, I have shared your web site in my social networks!

  4. I’ve been browsing online greater than 3 hours nowadays, yet I never found any interesting article like yours.

    It is pretty worth sufficient for me. In my opinion,
    if all website owners and bloggers made good content as you probably
    did, the internet can be a lot more helpful than ever before.

  5. Excellent blog here! Also your site loads up fast! What host are you using?
    Can I get your affiliate link to your host?
    I wish my website loaded up as fast as yours lol

  6. I loved as much as you will receive carried out right here.
    The sketch is tasteful, your authored material stylish.
    nonetheless, you command get bought an edginess over that you wish
    be delivering the following. unwell unquestionably come further formerly again since exactly the
    same nearly very often inside case you shield this hike.

  7. An outstanding share! I’ve just forwarded this onto a friend who has been conducting a little research on this.
    And he in fact bought me dinner due to the fact that I
    stumbled upon it for him… lol. So allow me to reword this….

    Thanks for the meal!! But yeah, thanks for spending some time to talk about this topic here on your website.

  8. I’m really loving the theme/design of your site. Do you
    ever run into any browser compatibility issues?

    A few of my blog audience have complained about my
    site not operating correctly in Explorer but looks great in Opera.
    Do you have any solutions to help fix this issue?

  9. Pingback: fun88 link
  10. Hey there! I know this is kinda off topic but I was wondering which blog platform are you
    using for this website? I’m getting fed up of WordPress because I’ve had problems with hackers and I’m looking at options for another platform.

    I would be fantastic if you could point me in the direction of a good
    platform.

  11. Hi there! Quick question that’s entirely off topic. Do you
    know how to make your site mobile friendly?

    My blog looks weird when viewing from my iphone 4. I’m trying to
    find a theme or plugin that might be able to resolve this problem.
    If you have any suggestions, please share. Cheers!

  12. I’m not sure why but this website is loading very
    slow for me. Is anyone else having this issue or
    is it a problem on my end? I’ll check back later on and
    see if the problem still exists.

  13. No matter if some one searches for his necessary thing, so he/she needs to be available that in detail, so that
    thing is maintained over here.

  14. What’s Taking place i am new to this, I stumbled upon this I have found It
    absolutely helpful and it has helped me out loads.

    I am hoping to contribute & aid different customers like its
    helped me. Good job.

  15. You could definitely see your enthusiasm within the
    article you write. The world hopes for more passionate writers like you who aren’t afraid to mention how they believe.

    All the time follow your heart.

Leave a Reply

Your email address will not be published.

*