/** * Returns an instance of the Storage object * @return \mithra62\BackupPro\Backup\Storage */ public function getStorage() { if (is_null($this->storage)) { $this->storage = new Backup\Storage($this->getStoragePath()); $this->storage->setServices($this->getServices()); } return $this->storage; }
/** * Runs the tests to make sure the backup directories exist and are writable * @param \mithra62\BackupPro\Backup\Storage $storage * @return \mithra62\BackupPro\Errors */ public function checkBackupDirs(\mithra62\BackupPro\Backup\Storage $storage) { $errors = array(); $index = dirname(__FILE__) . '/../index.html'; if (!is_writable($storage->getBackupDir())) { $errors[] = 'db_dir_missing'; $errors[] = 'files_dir_missing'; } else { if (!file_exists($storage->getDbBackupDir())) { if (!mkdir($storage->getDbBackupDir())) { $errors[] = 'db_dir_missing'; } else { @copy($index, $storage->getDbBackupDir() . '/index.html'); } } elseif (!is_writable($storage->getDbBackupDir())) { $errors[] = 'db_dir_not_writable'; } if (!file_exists($storage->getFileBackupDir())) { if (!mkdir($storage->getFileBackupDir())) { $errors[] = 'files_dir_missing'; } else { @copy($index, $storage->getFileBackupDir() . '/index.html'); } } elseif (!is_writable($storage->getFileBackupDir())) { $errors[] = 'files_dir_not_writable'; } if (!file_exists($storage->getDbBackupDir() . '/.meta')) { if (!mkdir($storage->getDbBackupDir() . '/.meta')) { $errors[] = 'db_dir_meta_missing'; } } if (!file_exists($storage->getFileBackupDir() . '/.meta')) { if (!mkdir($storage->getFileBackupDir() . '/.meta')) { $errors[] = 'files_dir_meta_missing'; } } } return $this; }