mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Set backup.php task
This commit is contained in:
@@ -633,7 +633,6 @@ $register->set('db', function () {
|
||||
$dbPass = App::getEnv('_APP_DB_PASS', '');
|
||||
$dbScheme = App::getEnv('_APP_DB_SCHEMA', '');
|
||||
|
||||
var_dump($dbHost, $dbPort, $dbUser, $dbPass, $dbScheme);
|
||||
$pdo = new PDO("mysql:host={$dbHost};port={$dbPort};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array(
|
||||
PDO::ATTR_TIMEOUT => 3, // Seconds
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
|
||||
+9
-17
@@ -3,7 +3,6 @@
|
||||
global $cli, $register;
|
||||
|
||||
use Utopia\CLI\Console;
|
||||
use Appwrite\Migration\Migration;
|
||||
use Utopia\App;
|
||||
use Utopia\Cache\Cache;
|
||||
use Utopia\Cache\Adapter\None;
|
||||
@@ -13,53 +12,46 @@ use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Authorization;
|
||||
use Utopia\Database\Validator\UID;
|
||||
|
||||
#docker compose exec appwrite backup --project=1
|
||||
#docker compose exec appwrite backup --projectId=1
|
||||
|
||||
$cli
|
||||
->task('backup')
|
||||
->param('projectId', '', new UID(), 'Project id to backupo', false)
|
||||
->action(function ($projectId) use ($register) {
|
||||
|
||||
var_dump($projectId);
|
||||
Console::exit(1);
|
||||
|
||||
Authorization::disable();
|
||||
// if (!array_key_exists($version, Migration::$versions)) {
|
||||
// Console::error("Version {$version} not found.");
|
||||
// Console::exit(1);
|
||||
// return;
|
||||
// }
|
||||
|
||||
$app = new App('UTC');
|
||||
|
||||
// Console::success('Starting Data Migration to version ' . $version);
|
||||
Console::success('Starting Data Backup for project ' . $projectId);
|
||||
|
||||
$db = $register->get('db', true);
|
||||
|
||||
$cache = new Cache(new None());
|
||||
|
||||
// todo: we want the adapter dynamic.
|
||||
$projectDB = new Database(new MariaDB($db), $cache);
|
||||
$projectDB->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
||||
|
||||
$consoleDB = new Database(new MariaDB($db), $cache);
|
||||
$consoleDB->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
|
||||
$consoleDB->setNamespace('_project_console');
|
||||
$consoleDB->setNamespace('_console');
|
||||
|
||||
$console = $app->getResource('console');
|
||||
// $console = $app->getResource('console');
|
||||
//$project = $consoleDB->find('projects', [Query::equal('$uid', [$projectId])]);
|
||||
$project = Authorization::skip(fn() => $consoleDB->getDocument('projects', $projectId));
|
||||
$project = $consoleDB->getDocument('projects', $projectId);
|
||||
|
||||
var_dump($project);
|
||||
|
||||
if ($project->getId() === 'console' && $project->getInternalId() !== 'console') {
|
||||
// todo: how not to choose console.?
|
||||
// todo: make sure not to backup console?
|
||||
}
|
||||
|
||||
|
||||
// $migration
|
||||
// ->setProject($project, $projectDB, $consoleDB)
|
||||
// ->setPDO($register->get('db'))
|
||||
// ->execute();
|
||||
|
||||
|
||||
Swoole\Event::wait(); // Wait for Coroutines to finish
|
||||
Console::success('Complete');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user