/** * @param string $storageType * @param string $directoryPath * @param DateTime $olderThan * @throws \BackupManager\Filesystems\FilesystemTypeNotSupported */ public function run($storageType, $directoryPath, DateTime $olderThan) { $sequence = new Sequence(); $fileSystem = $this->filesystems->get($storageType); $fileSystem->addPlugin(new ListWith()); // delete old files which are not modified after specified time $sequence->add(new Tasks\Storage\DeleteOldFiles($fileSystem, $directoryPath, $olderThan)); $sequence->execute(); }
/** * @param string $sourceType * @param string $sourcePath * @param string $databaseName * @param null $compression * @throws \BackupManager\Filesystems\FilesystemTypeNotSupported * @throws \BackupManager\Config\ConfigFieldNotFound * @throws \BackupManager\Compressors\CompressorTypeNotSupported * @throws \BackupManager\Databases\DatabaseTypeNotSupported * @throws \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 string $database * @param string $destination * @param string $destinationPath * @param string $compression * @throws \BackupManager\Filesystems\FilesystemTypeNotSupported * @throws \BackupManager\Config\ConfigFieldNotFound * @throws \BackupManager\Compressors\CompressorTypeNotSupported * @throws \BackupManager\Databases\DatabaseTypeNotSupported * @throws \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(); }