/** * @param $sourceType * @param $sourcePath * @param $databaseName * @param null $compression * @throws \BigName\BackupManager\Filesystems\FilesystemTypeNotSupported * @throws \BigName\BackupManager\Config\ConfigFieldNotFound * @throws \BigName\BackupManager\Compressors\CompressorTypeNotSupported * @throws \BigName\BackupManager\Databases\DatabaseTypeNotSupported * @throws \BigName\BackupManager\Config\ConfigNotFoundForConnection */ public function run($sourceType, $sourcePath, $databaseName, $compression = null) { $sequence = new Sequence(); // begin the life of a new working file $localFilesystem = $this->filesystems->get('local'); $workingFile = $this->getWorkingFile('local', uniqid() . basename($sourcePath)); // download or retrieve the archived backup file $sequence->add(new Tasks\Storage\TransferFile($this->filesystems->get($sourceType), $sourcePath, $localFilesystem, basename($workingFile))); // decompress the archived backup $compressor = $this->compressors->get($compression); $sequence->add(new Tasks\Compression\DecompressFile($compressor, $workingFile, $this->shellProcessor)); $workingFile = $compressor->getDecompressedPath($workingFile); // restore the database $sequence->add(new Tasks\Database\RestoreDatabase($this->databases->get($databaseName), $workingFile, $this->shellProcessor)); // cleanup the local copy $sequence->add(new Tasks\Storage\DeleteFile($localFilesystem, basename($workingFile))); $sequence->execute(); }
/** * @param $database * @param $destination * @param $destinationPath * @param $compression * @throws \BigName\BackupManager\Filesystems\FilesystemTypeNotSupported * @throws \BigName\BackupManager\Config\ConfigFieldNotFound * @throws \BigName\BackupManager\Compressors\CompressorTypeNotSupported * @throws \BigName\BackupManager\Databases\DatabaseTypeNotSupported * @throws \BigName\BackupManager\Config\ConfigNotFoundForConnection */ public function run($database, $destination, $destinationPath, $compression) { $sequence = new Sequence(); // begin the life of a new working file $localFilesystem = $this->filesystems->get('local'); $workingFile = $this->getWorkingFile('local'); // dump the database $sequence->add(new Tasks\Database\DumpDatabase($this->databases->get($database), $workingFile, $this->shellProcessor)); // archive the dump $compressor = $this->compressors->get($compression); $sequence->add(new Tasks\Compression\CompressFile($compressor, $workingFile, $this->shellProcessor)); $workingFile = $compressor->getCompressedPath($workingFile); // upload the archive $sequence->add(new Tasks\Storage\TransferFile($localFilesystem, basename($workingFile), $this->filesystems->get($destination), $compressor->getCompressedPath($destinationPath))); // cleanup the local archive $sequence->add(new Tasks\Storage\DeleteFile($localFilesystem, basename($workingFile))); $sequence->execute(); }
/** * Execute the sequence. */ protected function execute() { $this->sequence->execute(); }