if (empty($instanceId)) { $hostname = gethostname() . '.'; $instance = $clientHelper->getInstanceByHostname($hostname); $instanceId = $instance['InstanceId']; } else { $instance = $clientHelper->getInstanceById($instanceId); } $instanceName = $clientHelper->resolveInstanceName($instance); $console->writeLine("Creating snapshots of {$instanceName}"); $volumes = $clientHelper->getVolumesByInstance($instanceId); if (count($volumes) === 0) { throw new Exception('No volumes found'); } $toBackup = array(); foreach ($volumes as $volume) { $attachment = $clientHelper->getVolumeAttachmentForInstance($volume['Attachments'], $instanceId); $volumeId = $attachment['VolumeId']; $device = $attachment['Device']; if (in_array($volumeId, $exclusions) || in_array($device, $exclusions)) { $console->writeLine("Excluding {$volumeId} on {$device}", Color::YELLOW); } else { array_push($toBackup, array('volumeId' => $volumeId, 'device' => $device)); $console->writeLine("Found {$volumeId} on {$device}", Color::GRAY); } } if (!$dryRun) { $console->writeLine("Starting snapshots"); $snapshotIds = array(); foreach ($toBackup as $backup) { $volumeId = $backup['volumeId']; $device = $backup['device'];