src/Commands/RsyncCommand.php
protected function rsync($site_env_id, $src, $dest, array $rsyncOptions)
    {
        list($site, $env) = $this->getSiteEnv($site_env_id);
        $env_id = $env->getName();

        $siteInfo = $site->serialize();
        $site_id = $siteInfo['id'];

        // Stipulate the temporary directory to use iff the destination is remote.
        $tmpdir = '';
        if ($dest[0] == ':') {
            $tmpdir = '~/tmp';
        }

        $siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:";

        $src = preg_replace('/^:/', $siteAddress, $src);
        $dest = preg_replace('/^:/', $siteAddress, $dest);

        // Get the rsync options string. If the user did not pass
        // in any mode options (e.g. '-r'), then add in the default.
        $rsyncOptionString = implode(' ', $rsyncOptions);
        if (!preg_match('/(^| )-[^-]/', $rsyncOptionString)) {
            $rsyncOptionString = "-rlIpz $rsyncOptionString";
        }
        // Add in a tmp-dir option if one was not already specified
        if (!empty($tmpdir) && !preg_match('/(^| )--temp-dir/', $rsyncOptionString)) {
            $rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates";
        }

        $this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsyncOptionString $src $dest"]);
        $this->passthru("rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' ");
    }
protected function rsync($site_env_id, $src, $dest, array $rsyncOptions)
    {
        list($site, $env) = $this->getSiteEnv($site_env_id);
        $env_id = $env->getName();

        $siteInfo = $site->serialize();
        $site_id = $siteInfo['id'];

        // Stipulate the temporary directory to use iff the destination is remote.
        $tmpdir = '';
        if ($dest[0] == ':') {
            $tmpdir = '~/tmp';
        }

        $siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:";

        $src = preg_replace('/^:/', $siteAddress, $src);
        $dest = preg_replace('/^:/', $siteAddress, $dest);

        // Get the rsync options string. If the user did not pass
        // in any mode options (e.g. '-r'), then add in the default.
        $rsyncOptionString = implode(' ', $rsyncOptions);
        if (!preg_match('/(^| )-[^-]/', $rsyncOptionString)) {
            $rsyncOptionString = "-rlIpz $rsyncOptionString";
        }
        // Add in a tmp-dir option if one was not already specified
        if (!empty($tmpdir) && !preg_match('/(^| )--temp-dir/', $rsyncOptionString)) {
            $rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates";
        }

        $this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsyncOptionString $src $dest"]);
        $this->passthru("rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' ");
    }
protected function rsync ( $ site_env_id , $ src , $ dest , array $ rsyncOptions ) { list ( $ site , $ env ) = $ this -> getSiteEnv ( $ site_env_id ) ; $ env_id = $ env -> getName ( ) ; $ siteInfo = $ site -> serialize ( ) ; $ site_id = $ siteInfo [ 'id' ] ; // Stipulate the temporary directory to use iff the destination is remote. $ tmpdir = '' ; if ( $ dest [ 0 ] == ':' ) { $ tmpdir = '~/tmp' ; } $ siteAddress = "$env_id.$site_id@appserver.$env_id.$site_id.drush.in:" ; $ src = preg_replace ( '/^:/' , $ siteAddress , $ src ) ; $ dest = preg_replace ( '/^:/' , $ siteAddress , $ dest ) ; // Get the rsync options string. If the user did not pass // in any mode options (e.g. '-r'), then add in the default. $ rsyncOptionString = implode ( ' ' , $ rsyncOptions ) ; if ( ! preg_match ( '/(^| )-[^-]/' , $ rsyncOptionString ) ) { $ rsyncOptionString = "-rlIpz $rsyncOptionString" ; } // Add in a tmp-dir option if one was not already specified if ( ! empty ( $ tmpdir ) && ! preg_match ( '/(^| )--temp-dir/' , $ rsyncOptionString ) ) { $ rsyncOptionString = "$rsyncOptionString --temp-dir=$tmpdir --delay-updates" ; } $ this -> log ( ) -> notice ( 'Running {cmd}' , [ 'cmd' => "rsync $rsyncOptionString $src $dest" ] ) ; $ this -> passthru ( "rsync $rsyncOptionString --ipv4 --exclude=.git -e 'ssh -p 2222' '$src' '$dest' " ) ; }
Call rsync to or from the specified site.

@param string $site_env_id Remote site
@param string $src Source path to copy from. Start with ":" for remote.
@param string $dest Destination path to copy to. Start with ":" for remote.
Call rsync to or from the specified site .