Yo

See attached for first cut of lftp drush task. lftp is a poor mans rsync. Even these days we are all occasionally inflicted with the pain of having to deploy to a live site over ftp, and this allows that.

It's currently (probably) DANGEROUS. I've literally only tested it in one circumstance.

Provides drush lsync command (lftp-sync)

# drush lsync @project.local:%files @project.live:%files

- Code based on (copied and pasted from) drush core rsync. Ultimately it could make sense to make rsync more generic to allow multiple providers (rsync or lftp). That could be cleaner. On the other hand, writing a seperate command is quicker to get done.
- Works against drush head as at Feb 10 2011
- This is the first time I've looked at site alias code, at 3:30am and really don't understand what it's doing. At all. I copied sitealias_evaluate_path into my own drush_lftp_sitealias_evaluate_path as the original seems hard coded to expect rsync relevant parameters (remote host etc). So for purposes of first version I duplicate.
- This expects your site alias file to have an 'lftp' array. E.G

$aliases['live'] = array(
  'uri' => 'mydomain.com',
  'root' => '/public_html',
  'lftp' => array(
    'protocol' => 'sftp://',
    'user' => 'mydomainuser',
    'pass' => 'mydomainpass',
    'host' => 'mydomainhost.com',
    'root' => '/public_html'
  ),
  'path-aliases' => array (
    '%files' => 'sites/default/files',
  ),
);

The extra lftp array made sense at 3:30am "getting it to work". Probably not in real life.

Hoping someone who knows what they doing with drush site aliases will pick this up and clean it up.

CommentFileSizeAuthor
#1 lftp.drush_.inc_.txt13.09 KBwillieseabrook

Comments

willieseabrook’s picture

StatusFileSize
new13.09 KB
willieseabrook’s picture

Additionally, I havn't set up the possible parameters like the rsync command.

lftp options are as follows:


            -c, --continue      continue a mirror job if possible
            -e, --delete        delete files not present at remote site
                --delete-first       delete old files before transferring new ones
                --depth-first        descend into subdirectories before transferring files
            -s, --allow-suid         set suid/sgid bits according to remote site
                --allow-chown   try to set owner and group on files
                --ascii         use ascii mode transfers (implies --ignore-size)
                --ignore-time        ignore time when deciding whether to download
                --ignore-size        ignore size when deciding whether to download
                --only-missing  download only missing files
                --only-existing download only files already existing at target
            -n, --only-newer    download only newer files (-c won’t work)
                --no-empty-dirs don’t create empty directories (implies --depth-first)
            -r, --no-recursion  don’t go to subdirectories
                --no-symlinks   don’t create symbolic links
            -p, --no-perms      don’t set file permissions
                --no-umask      don’t apply umask to file modes
            -R, --reverse       reverse mirror (put files)
            -L, --dereference   download symbolic links as files
            -N, --newer-than=SPEC    download only files newer than specified time
                --on-change=CMD      execute the command if anything has been changed
                --older-than=SPEC    download only files older than specified time
                --size-range=RANGE   download only files with size in specified range
            -P, --parallel[=N]  download N files in parallel
                --use-pget[-n=N]     use pget to transfer every single file
                --loop          loop until no changes found
            -i RX, --include RX include matching files
            -x RX, --exclude RX exclude matching files
            -I GP, --include-glob GP include matching files
            -X GP, --exclude-glob GP exclude matching files
            -v, --verbose[=level]    verbose operation
                --log=FILE      write lftp commands being executed to FILE
                --script=FILE        write lftp commands to FILE, but don’t execute them
                --just-print, --dry-run   same as --script=-
                --use-cache          use cached directory listings
            --Remove-source-files    remove files after transfer (use with caution)
            -a             same as --allow-chown --allow-suid --no-umask

greg.1.anderson’s picture

Status: Needs review » Needs work

Not opposed to this at all, if it was cleaned up as described above.

Perhaps even better would be a change to drush core that allowed the rsync command to use some other transport mechanism if appropriate options were set. I may have to do this shortly to support sql-sync on Windows. Once that is available, perhaps lftp / sftp might be another transport mechanism to consider.