Archive for February, 2009

A simple, non bloated script for Amazon S3 backups (Linux, easy portable) – II – recurse to subdirs

To follow this, please read this post first.

We needed to backup our images from to S3 for our premium members so we were searching for a simple script to do that one time. As in my previous post; there is no such thing. Bloated, uninstallable shit is the only thing there is.

So I changed the code a bit and added;

foreach($_SERVER["argv"] as $d) {
recurse_copy($d, $d);

function recurse_copy($d, $org) {
foreach(glob("$d/*") as $d1) {
if ($d1=='..' || $d1=='.') continue;
if (is_dir($d1)) {
recurse_copy($d1, $org);
} else {
// put on s3
global $s3;
global $bucket;
$s3->putObjectFile($d1, $bucket, $d1);
echo "Storing: ".$d1."n";

below the last;