This commit is contained in:
Bozhidar 2024-05-16 12:52:08 +03:00
parent 3d483c0dcc
commit 09416aa23f
2 changed files with 30 additions and 7 deletions

View file

@ -7,11 +7,20 @@ use App\Backup\Abstract\BackupConfigBase;
class MicroweberBackupConfig extends BackupConfigBase
{
public array $excludePaths = [
'/storage/framework/cache',
'/storage/framework/views',
'/userfiles/cache',
'/userfiles/media/thumbnails',
'/storage/framework/sessions',
'/home/*/public_html/storage/framework/cache',
'/home/*/public_html/storage/framework/views',
'/home/*/public_html/userfiles/cache',
'/home/*/public_html/userfiles/media/thumbnails',
'/home/*/public_html/storage/framework/sessions',
'/home/*/domains/*/public_html',
'/home/*/domains/*/public_html/storage/framework/cache',
'/home/*/domains/*/public_html/storage/framework/views',
'/home/*/domains/*/public_html/userfiles/cache',
'/home/*/domains/*/public_html/userfiles/media/thumbnails',
'/home/*/domains/*/public_html/storage/framework/sessions',
];
}

View file

@ -239,6 +239,19 @@ class Backup extends Model
$shellFileContent .= 'echo "Backup Phyre Panel Config"'. PHP_EOL;
$shellFileContent .= 'cp '.base_path().'/phyre-config.ini '.$backupTempPath.'/phyre-config.ini'. PHP_EOL;
// Make exclude.lst file
$backupManagerConfig = app()->backupManager->getConfigs([
'microweber'
]);
$excludeListContent = '';
if (isset($backupManagerConfig['excludePaths'])) {
foreach ($backupManagerConfig['excludePaths'] as $exclude) {
$excludeListContent .= $exclude . PHP_EOL;
}
}
$excludeListPath = $backupTempPath.'/exclude.lst';
file_put_contents($excludeListPath, $excludeListContent);
if ($this->backup_type == 'full') {
// Export Phyre Panel Hosting Subscription
$findHostingSubscription = HostingSubscription::all();
@ -251,7 +264,8 @@ class Backup extends Model
$shellFileContent .= 'mkdir -p ' . $hostingSubscriptionPath . PHP_EOL;
// cp -r (copy recursively, also copy hidden files)
$shellFileContent .= 'cp -r /home/' . $hostingSubscription->system_username . '/ ' . $hostingSubscriptionsMainPath . PHP_EOL;
// $shellFileContent .= 'cp -r /home/' . $hostingSubscription->system_username . '/ ' . $hostingSubscriptionsMainPath . PHP_EOL;
$shellFileContent .= "rsync -av --exclude-from='$excludeListPath' /home/$hostingSubscription->system_username/ " . $hostingSubscriptionPath . PHP_EOL;
$shellFileContent .= 'mkdir -p ' . $hostingSubscriptionPath . '/databases' . PHP_EOL;
@ -278,7 +292,7 @@ class Backup extends Model
}
// With find, we can search for all files,directories (including hidden) in the current directory and zip them
$shellFileContent .= 'cd '.$backupTempPath .' && find . -exec zip --symlinks -r '.$backupFilePath.' {} \;'. PHP_EOL;
$shellFileContent .= 'cd '.$backupTempPath .' && find . -exec zip -1 --symlinks -r '.$backupFilePath.' {} \;'. PHP_EOL;
$shellFileContent .= 'rm -rf '.$backupTempPath.PHP_EOL;
$shellFileContent .= 'echo "Backup complete"' . PHP_EOL;