video tests

This commit is contained in:
shimon
2023-02-23 19:18:58 +02:00
parent 70e4bd844e
commit 72d1bfb4c2
7 changed files with 104 additions and 4 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ _APP_CONNECTIONS_DB_CONSOLE=db_fra1_01=mariadb://user:password@mariadb:3306/appw
_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_STORAGE=DOSpaces://JFFSCKTIMLOG2GBVA2IA:oPNeHob8TXVYtq68gQ0DiIbp9qPTJRRAO2LL4qDzTYI@null:0/utopia-storage-tests?region=nyc3
_APP_STORAGE_ANTIVIRUS=disabled
_APP_STORAGE_ANTIVIRUS_HOST=clamav
_APP_STORAGE_ANTIVIRUS_PORT=3310
+2 -1
View File
@@ -132,7 +132,8 @@ RUN chmod +x /usr/local/bin/doctor && \
chmod +x /usr/local/bin/worker-mails && \
chmod +x /usr/local/bin/worker-messaging && \
chmod +x /usr/local/bin/worker-webhooks && \
chmod +x /usr/local/bin/worker-usage
chmod +x /usr/local/bin/worker-usage && \
chmod +x /usr/local/bin/folder-backup
# Letsencrypt Permissions
RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
php /usr/src/code/app/cli.php folder-backup $@
+1 -1
View File
@@ -63,7 +63,7 @@
"utopia-php/logger": "0.3.*",
"utopia-php/messaging": "0.1.*",
"utopia-php/registry": "0.5.*",
"utopia-php/storage": "0.13.*",
"utopia-php/storage": "dev-feat-transfer as 0.13.2",
"utopia-php/swoole": "0.5.*",
"utopia-php/websocket": "0.1.*",
"resque/php-resque": "1.3.6",
+17
View File
@@ -581,6 +581,23 @@ services:
- _APP_MAINTENANCE_RETENTION_AUDIT
- _APP_MAINTENANCE_RETENTION_SCHEDULES
appwrite-folder-backup:
entrypoint: folder-backup
<<: *x-logging
container_name: appwrite-folder-backup
image: appwrite-dev
networks:
- appwrite
volumes:
- ./app:/usr/src/code/app
- ./src:/usr/src/code/src
- appwrite-certificates:/storage/certificates:rw
- ./vendor/utopia-php/cli:/usr/src/code/vendor/utopia-php/cli
environment:
- _APP_ENV
- _APP_MAINTENANCE_INTERVAL
- _APP_CONNECTIONS_STORAGE
appwrite-worker-usage:
entrypoint: worker-usage
<<: *x-logging
+3 -1
View File
@@ -15,6 +15,7 @@ use Appwrite\Platform\Tasks\SSL;
use Appwrite\Platform\Tasks\Vars;
use Appwrite\Platform\Tasks\Version;
use Appwrite\Platform\Tasks\VolumeSync;
use Appwrite\Platform\Tasks\FolderBackup;
class Tasks extends Service
{
@@ -33,6 +34,7 @@ class Tasks extends Service
->addAction(Migrate::getName(), new Migrate())
->addAction(SDKs::getName(), new SDKs())
->addAction(VolumeSync::getName(), new VolumeSync())
->addAction(Specs::getName(), new Specs());
->addAction(Specs::getName(), new Specs())
->addAction(FolderBackup::getName(), new FolderBackup());
}
}
@@ -0,0 +1,77 @@
<?php
namespace Appwrite\Platform\Tasks;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Database\DateTime;
use Utopia\DSN\DSN;
use Utopia\Platform\Action;
use Utopia\Storage\Device\DOSpaces;
use Utopia\Storage\Device\Local;
class FolderBackup extends Action
{
public static function getName(): string
{
return 'folder-backup';
}
public function __construct()
{
$this
->desc('Folder backup and restore process')
->callback(fn () => $this->action());
}
public function action(): void
{
Console::title('Folder backup V1');
Console::success(APP_NAME . ' folder backup process v1 has started');
$interval = (int) App::getEnv('_APP_MAINTENANCE_INTERVAL', '86400');
Console::loop(function () use ($interval) {
$folders = [
'cert' => APP_STORAGE_CERTIFICATES,
];
foreach ($folders as $key => $folder) {
$root = new Local($folder);
$filename = $key . '-' . date("Y-m-d") . '.tar.gz';
$source = $root->getRoot() . '/' . $filename;
$destination = '/' . $key . '/' . $filename;
$content = $root->getRoot() . '/*';
// for ($i = 0; $i < 1000; $i++) {
// file_put_contents($root->getRoot() . '/' . $i . '.txt', '');
// }
$stdout = '';
$stderr = '';
Console::execute(
'tar --exclude ' . $filename . ' -zcf ' . $source . ' ' . $content,
'',
$stdout,
$stderr
);
try {
$connection = App::getEnv('_APP_CONNECTIONS_STORAGE', '');
$dsn = new DSN($connection);
$remote = new DOSpaces(
'/',
$dsn->getUser(),
$dsn->getPassword(),
$dsn->getPath(),
$dsn->getParam('region')
);
$result = $root->transfer($source, $destination, $remote);
var_dump($result);
Console::log('done');
} catch (\Exception $e) {
Console::error($e->getMessage());
}
}
}, $interval);
}
}