# Rsync Deployment setup à la bummzack ## Setup First, you'll need to install the deployer rsync recipe. To get the recipe for deployer 3.x, use: composer require --dev deployphp/recipes ~3.0 The deploy.php recipe assumes, that you have a `dev-deploy` folder in your project-folder. This folder **must** contain an `.htaccess` and `_ss_environment.php` file, prefixed with the stage it should be deployed to. It also **must** contain a `rsync.filter.txt` file with the Rsync filter-rules (these are usually the same for each project). So these are the files that should be in `dev-deploy` if you have a stage named `live` and `staging`: - `live.htaccess` (*required*): The *.htaccess* file that will be copied to the live server. - `live_ss_environment.php` (*required*): The *_ss_environement.php* file that will be copied to the live server. - `staging.htaccess` (*required*): The *.htaccess* file that will be copied to the staging server. - `staging_ss_environment.php` (*required*): The *_ss_environement.php* file that will be copied to the staging server. - `rsync.filter.txt` (*required*): The filter rules that should be used for the rsync-task. - `robots.txt` (*optional*): A robots.txt that will be copied to all stages. ## Tasks These are the additional tasks that are added by the `deploy.php` recipe. - **my_cnf** creates a file called `~/.my_cnf` on the remote server that will contain the DB credentials for mysqldumps that won't require user credentials via command-line. - **installcomposer** will install composer in `~/bin/` on the remote server - **setup** just runs **my_cnf** and **installcomposer** - **rsync** copies your website data via rsync (this is being run during a standard "deploy") - **silverstripe:prepare** can be used to copy a .htaccess and .web.config file for your assets folder (this is being run during a standard "deploy") - **silverstripe:dump** creates a database dump (this is being run during a standard "deploy") - **silverstripe:migrate** runs `dev/build?flush=1` (this is being run during a standard "deploy") Note: The `rsync` task will run `gulp release` locally. So make sure there's a gulp task for that. See: https://gist.github.com/bummzack/e49517fb7a9d9f7fae64b6838ea8986f to see my gulp setup. ## Description of rsync.filter.txt The default contents of rsync.filter.txt are: ```txt - */.DS_Store - */.git - dev-* + themes/*** + mysite/*** + composer.* - * ``` This basically copies `themes` and `mysite` and everything within these directories, **unless** the file/dir is named `.DS_Store`, `.git` or starts with `dev-`. `composer.json` and `composer.lock` are being copied as well, everything else is ignored.