".$backupPath; system($cmd); if (!file_exists($backupPath)) { exit("ERROR: failed to create backup file!".PHP_EOL); } // instantiate the S3 manager $s3 = new S3(awsAccessKey, awsSecretKey); // check if the backup bucket already exists $bucks = $s3->listBuckets(); $buckId = array_search($bucketName, $bucks); if ($buckId<0) { // create the backup bucket if (!$s3->putBucket($bucketName, S3::ACL_PUBLIC_READ)) { exit("ERROR: failed to create backup bucket!".PHP_EOL); } } // put the backup file into the bucket if (!$s3->putObjectFile($backupPath, $bucketName, baseName($backupPath), S3::ACL_PUBLIC_READ)) { exit("ERROR: failed to put file '".$backupPath."' to backup bucket '".$bucketName."'".PHP_EOL); } // perform the cleanup, if needed if (1==CLEANUP_TYPE) { // remove the backup file unlink($backupPath); } else if (2==CLEANUP_TYPE) { // clear the backup directory foreach(glob($backupDir.'/*') as $sf) { if (!is_dir($sf)) { unlink($sf); } } } ?>