diff --git a/.env b/.env index e0ae56eeab..fe92d96822 100644 --- a/.env +++ b/.env @@ -27,14 +27,14 @@ _APP_DB_PASS=password _APP_DB_ROOT_PASS=rootsecretpassword _APP_CONNECTIONS_MAX=3100 _APP_POOL_CLIENTS=14 -_APP_CONNECTIONS_DB_REPLICAS=db_fra1_02=mariadb://root:rootsecretpassword@mariadb:3306/appwrite +_APP_CONNECTIONS_DB_REPLICAS=db_fra1_03=mariadb://root:rootsecretpassword@mariadb:3306/appwrite _APP_CONNECTIONS_DB_PROJECT=db_fra1_02=mariadb://user:password@mariadb:3306/appwrite _APP_CONNECTIONS_DB_CONSOLE=db_fra1_01=mariadb://user:password@mariadb:3306/appwrite _APP_CONNECTIONS_CACHE=redis_fra1_01=redis://redis:6379 _APP_CONNECTIONS_QUEUE=redis_fra1_01=redis://redis:6379 _APP_CONNECTIONS_PUBSUB=redis_fra1_01=redis://redis:6379 _APP_CONNECTIONS_STORAGE=local://localhost -_APP_CONNECTIONS_BACKUPS_STORAGE=dospaces://ACCESS:SECRET@default/backups-v1?region=fra1 +_APP_CONNECTIONS_BACKUPS_STORAGE=dospaces://DO00QM68PV7HQD77DQVF:l2Zh7eH5aoMKgEe3h71jD9nxzULvdrRtkDTQUYkaES0@default/backups-v1?region=fra1 _APP_STORAGE_ANTIVIRUS=disabled _APP_STORAGE_ANTIVIRUS_HOST=clamav _APP_STORAGE_ANTIVIRUS_PORT=3310 diff --git a/docker-compose.yml b/docker-compose.yml index 8472f93708..1e3fea90bd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -750,7 +750,7 @@ services: # - SMARTHOST_PORT=587 xtrabackup: - image: percona/percona-xtrabackup:latest + image: percona/percona-xtrabackup:8.0.33 container_name: xtrabackup command: sleep infinity volumes: diff --git a/src/Appwrite/Platform/Tasks/Backup.php b/src/Appwrite/Platform/Tasks/Backup.php index d3ff833780..102fabe40a 100644 --- a/src/Appwrite/Platform/Tasks/Backup.php +++ b/src/Appwrite/Platform/Tasks/Backup.php @@ -106,8 +106,7 @@ class Backup extends Action $start = microtime(true); $time = date('Y_m_d_H_i_s'); - self::log('--- Backup Start --- '); - self::log('--- Creating backup ' . $time . ' --- '); + self::log('--- Backup Start ' . $time . ' --- '); $filename = $time . '.tar.gz'; $local = new Local(self::BACKUPS_PATH . '/' . $this->database . '/full/' . $time); @@ -120,7 +119,7 @@ class Backup extends Action $this->tar($backups, $tarFile); $this->upload($tarFile, $local); - self::log('--- Backup End ' . (microtime(true) - $start) . ' seconds --- ' . PHP_EOL . PHP_EOL); + self::log('--- Backup Finish ' . (microtime(true) - $start) . ' seconds --- ' . PHP_EOL . PHP_EOL); } public function fullBackup(string $target) @@ -159,14 +158,13 @@ class Backup extends Action ]; $cmd = 'docker exec ' . $this->xtrabackupContainerId . ' ' . implode(' ', $args); - self::log($cmd); + self::log('Xtrabackup start'); shell_exec($cmd); $stderr = shell_exec('tail -1 ' . $logfile); - self::log($stderr); if (!str_contains($stderr, 'completed OK!') || !file_exists($target . '/xtrabackup_checkpoints')) { - Console::error('Backup failed'); + Console::error(date('Y-m-d H:i:s') . ' Backup failed:' . $stderr); Console::exit(); } @@ -178,15 +176,14 @@ class Backup extends Action public function tar(string $directory, string $file) { + self::log('Tar start'); + $stdout = ''; $stderr = ''; - $cmd = 'cd ' . $directory . ' && tar zcf ' . $file . ' . && cd ' . getcwd(); - self::log($cmd); Console::execute($cmd, '', $stdout, $stderr); - self::log($stdout); if (!empty($stderr)) { - Console::error($stderr); + Console::error(date('Y-m-d H:i:s') . ' Tar failed:' . $stderr); Console::exit(); } @@ -196,15 +193,15 @@ class Backup extends Action } $filesize = \filesize($file); - self::log('Tar file size is: ' . ceil($filesize / 1024 / 1024) . 'MB'); if ($filesize < (2 * 1024 * 1024)) { - Console::error('File size is very small: ' . $file); + Console::error('Tar file size is very small: ' . $file); Console::exit(); } } public function upload(string $file, Device $local) { + self::log('Upload start'); $filename = basename($file); if (!$this->s3->exists('/')) { @@ -213,7 +210,6 @@ class Backup extends Action } try { - self::log('Uploading: ' . $file); $destination = $this->s3->getRoot() . '/' . $filename; if (!$local->transfer($file, $destination, $this->s3)) {