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 http://www.picturepush.com 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);
}
exit;

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;


array_shift($_SERVER["argv"]);

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>