joro / typo3reversedeployment
Export DB and files to your TYPO3 dev installation
Installs: 3 251
Dependents: 1
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 5
Open Issues: 8
Requires
- php: ^7.2 || ^8.0
- symfony/process: ^5.3
Requires (Dev)
- phpstan/phpstan: ^0.12.99
- phpunit/phpunit: ^9.5
README
Features:
- Export TYPO3 Database and download (exclude tables)
- Download only referenced files to your local fileadmin
- Download specific folders like ./uploads or download entire fileadmin
Requirements:
- TYPO3 Console (>=4.6) on remote TYPO3 installation
- A SSH connection to the remote server
rsync
to download files- Works with TYPO3 7.x/8.x/9.x/10.x
⚠️ In version 2.0.0 ...->ssh('example.org'); changes to
...->setRemoteServer('example.org');
Security
Created temporary files should be protected from public access
Apache
The code will check for .htaccess
file within typo3temp/joro_typo3reversedeployment
and creates it as needed.
Example content:
deny from all
NGINX
Add this to your NGINX configuration to disabled public access of temp files
location ~ /\.(?!joro_typo3reversedeployment).* {
deny all;
}
Usage:
- Create a new file in folder
.reverse
, e.g..reverse/remote.php
<?php $reverseDeploy = new \JoRo\Typo3ReverseDeployment(); /** * Set server paths */ $reverseDeploy->setTypo3RootPath('/var/www/html/'); // optional: $reverseDeploy->setPhpPathAndBinary('/usr/local/bin/php_cli'); /** * Connect to Server */ $reverseDeploy->setUser('USERNAME'); $reverseDeploy->setRemoteServer('example.org'); // optional: $reverseDeploy->setPrivateKey(getenv('HOME') . '/.ssh/id_rsa'); // optional: $reverseDeploy->setSshPort(222); /** * Get database */ $reverseDeploy->setSqlExcludeTable(['sys_log']); $reverseDeploy->setSqlTarget("./tmp/"); $reverseDeploy->getDatabase(); /** * Get fileadmin */ // optional - download only used files: $reverseDeploy->setFileadminOnlyUsed(true); // optional - to download files in ddev docker container: $reverseDeploy->setLocalTempPath('/var/www/web/'); $reverseDeploy->setFileTarget("./fileadmin/"); $reverseDeploy->getFiles($ssh);
- Run
vendor/bin/typo3reverse
Add/remove methods for files include/exclude
Add/remove item to/from exludes array
$reverseDeploy->addExclude(["uploads"]); $reverseDeploy->removeExclude(["uploads"]);
Add/remove item to/from includes array
$reverseDeploy->addInclude(["uploads"]); $reverseDeploy->removeInclude(["uploads"]);
Use SSH-Key with passphrase
You can define your passphrase like shown in this example:
/** * Connect to Server */ $reverseDeploy->setPrivateKeyPassphrase('mypassword'); $reverseDeploy->setUser('USERNAME'); $reverseDeploy->setRemoteServer('example.org');
If you do not want to have your passphrase stored in a file, you can use an environment variable:
/** * Connect to Server */ $reverseDeploy->setPrivateKeyPassphrase(getenv('PASSPHRASE')); $reverseDeploy->setUser('USERNAME'); $reverseDeploy->setRemoteServer('example.org');
Then you can start the reverse deployment with a command like this:
PASSPHRASE=mypassword vendor/bin/typo3reverse
Build phar file
Using MacFJA/PharBuilder package to create PHAR file
For configuration see composer.json extra -> phar-builder
php -d phar.readonly=0 vendor/bin/phar-builder package