39 $snapshotPath = $this->_snapshot->getBackupPath();
43 new Phrase(
'Can\'t load snapshot archive')
58 if ($this->_snapshot->keepSourceFile() ===
false) {
59 $fsHelper->rm($tmpDir, [],
true);
60 $this->_ftpClient->delete($snapshotPath);
73 $this->_ftpClient = new \Magento\Framework\System\Ftp();
74 $this->_ftpClient->connect($this->_snapshot->getFtpConnectString());
75 }
catch (\Exception $e) {
77 new Phrase($e->getMessage())
90 $validationFilename =
'~validation-' . microtime(
true) .
'.tmp';
91 $validationFilePath = $this->_snapshot->getBackupsDir() .
'/' . $validationFilename;
93 $fh = @
fopen($validationFilePath,
'w');
96 if (!
is_file($validationFilePath)) {
98 new Phrase(
'Unable to validate ftp account')
102 $rootDir = $this->_snapshot->getRootDir();
103 $ftpPath = $this->_snapshot->getFtpPath() .
'/' . str_replace(
$rootDir,
'', $validationFilePath);
105 $fileExistsOnFtp = $this->_ftpClient->fileExists($ftpPath);
106 @
unlink($validationFilePath);
108 if (!$fileExistsOnFtp) {
110 new Phrase(
'Failed to validate ftp account')
123 $snapshotPath = $this->_snapshot->getBackupPath();
125 $archiver = new \Magento\Framework\Archive();
126 $archiver->unpack($snapshotPath, $tmpDir);
135 $tmpDir = $this->_snapshot->getBackupsDir() .
'/~tmp-' . microtime(
true);
140 throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions(
141 new Phrase(
'Failed to create directory %1', [$tmpDir])
155 $rootDir = $this->_snapshot->getRootDir();
157 $filesystemIterator = new \RecursiveIteratorIterator(
158 new \RecursiveDirectoryIterator(
$rootDir),
159 \RecursiveIteratorIterator::CHILD_FIRST
162 $iterator = new \Magento\Framework\Backup\Filesystem\Iterator\Filter(
164 $this->_snapshot->getIgnorePaths()
168 $ftpPath = $this->_snapshot->getFtpPath() .
'/' . str_replace(
$rootDir,
'',
$item->__toString());
169 $ftpPath = str_replace(
'\\',
'/', $ftpPath);
171 $this->_ftpClient->delete($ftpPath);
185 $filesystemIterator = new \RecursiveIteratorIterator(
186 new \RecursiveDirectoryIterator($tmpDir),
187 \RecursiveIteratorIterator::SELF_FIRST
190 $iterator = new \Magento\Framework\Backup\Filesystem\Iterator\Filter(
192 $this->_snapshot->getIgnorePaths()
195 foreach ($filesystemIterator as
$item) {
196 $ftpPath = $this->_snapshot->getFtpPath() .
'/' . str_replace($tmpDir,
'',
$item->__toString());
197 $ftpPath = str_replace(
'\\',
'/', $ftpPath);
199 if (
$item->isLink()) {
203 if (
$item->isDir()) {
204 $this->_ftpClient->mkdirRecursive($ftpPath);
206 $result = $this->_ftpClient->put($ftpPath,
$item->__toString());
208 throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions(
209 new Phrase(
'Failed to upload file %1 to ftp', [
$item->__toString()])
_uploadBackupToFtp($tmpDir)
mkdir($pathname, $mode=0777, $recursive=false, $context=null)