yostupload

an extremely easy-to-use command-line program
to upload or download files to/from a server
using options stored in a hidden file at the root of the local hierarchy.

You can run yostupload in any directory within your local copy of your web site. It will look recursively toward root until it finds a configuration file (.YostUploadRoot). Now yostupload knows your location within the local hierarchy, knows your upload preferences, and knows how to get to your server, so you don't have to specify a bunch of command arguments to get the job done. yostupload uses rsync or ftp to do the transfers. Also, you can use yostupload -l to ssh directly to the corresponding folder on the server.

Example:

1 Z% cd ~/website/computers
2 Z% yostupload -v mvredir mkredir
[ cd '/Users/neddie/website/' ] 
[ rsync --rsh 'ssh -l neddie' -rRhHLtp --bwlimit=3 --partial --progress computers/mvredir computers/mkredir DreamHost.com:public_html ]
building file list ... done
computers/
computers/mkredir/
computers/mkredir/index.html
computers/mvredir/
computers/mvredir/index.html

sent 24.43K bytes  received 64 bytes  5.34K bytes/sec
total size is 24.43K  speedup is 0.99
3 Z% yostupload -lv
yostupload: examining current directory 
[ ssh -t -l neddie DreamHost.com "cd 'public_html'/'computers' && exec $0 -l" ]
server 1 Z% pwd
/home/neddie/public_html/computers
server 2 Z% exit
Connection to DreamHost.com closed.
4 Z% yostupload -u mkredir/index.html
http://yourhost.com/computers/mkredir/index.html
5 Z% yostupload -R
/Users/neddie/website/.YostUploadRoot
6 Z% 

Usage summary

Usage:    yostupload [ -d [ -o dir ] ] [ -v ] [ -q ] [ -n ] [ -r rootFile ] \
           [ --rsync-args args ] [ path ... ]
yostupload -l [ -r rootFile ] [ path ]
yostupload -R [ -r rootFile ] [ path ]
yostupload -u [ -r rootFile ] [ path ]
yostupload -i user host remote-dir [ rsync-args ]

path defaults to the current directory.

Uploads files unless -d to download instead.

Or: use -l to ssh to the server. The remote shell’s current directory will correspond to path.

Or: use -R to output rootFile path.

Or: use -u to output the URL for path.

Or: use -i to quickly set up the current directory for use with yostupload.
The -i option usage creates a .YostUploadRoot file in the current directory so that from then on you can use yostupload there. Append --no-progress and/or --no-partial if you don't like the defaults.

All path arguments (files and/or folders) must be within a folder hierarchy that serves as a local staging area for a folder on the server. yostupload uploads (or downloads) everything between their corresponding locations in the local folder hierarchy and the server folder hierarchy.

The root of the local folder hierarchy is identified by the fact that it contains a parameters file called “.YostUploadRoot”. yostupload executes this file and expects it to output key-value pairs, as in this example output:

protocol rsync
command /usr/local/bin/rsync
host upload.yourhost.com
url https://somedomain.com/
port 12345
user neddie
dir public_html
rsync-args-up --bwlimit=48 --partial
finishUp echo Upload succeeded $(date)

Because “.YostUploadRoot” is executed, it can run another script containing favorite defaults, as this example does. Values from multiple lines with the same key are catenated.

Notes on the settings:

Use rsync if possible; ftp and sftp copy with world-readable permissions, and they aren't smart (like rsync is) about transferring only what needs to be transferred. The rsync command sets permissions on the server to match those in the local hierarchy, so when the destination is a public web site, local dirs should be searchable by all and local files should be readable by all; yostupload warns if some permissions are too restrictive for web access.

The -v option shows the rsync, ftp, or sftp transfer command actually used and puts the transfer command itself into verbose mode.

The -q option refrains from warning about files with restricted permissions.

The -n option sets -v and refrains from actually running the command.

The -r rootFile option specifies a different root filename instead of “.YostUploadRoot”.

The -o dir option argument is used as the destination directory for a download.

Notes

Yostupload works best with rsync, a shell command found on linux, BSD, Mac OS X, etc. For one thing, rsync transfers only things that have changed. For another thing, it uses a secure protocol, yet you can arrange things so you don’t have to enter your password every time—this works without storing the password in a local file. If your web hosting service is doesn’t support rsync for uploads and downloads, you might want to consider switching to DreamHost, which does.

Here’s a sample .YostUploadRoot file:

#!/bin/sh

echo host yourhost.com
echo user neddie
echo dir public_html
echo rsync-args-up --bwlimit=3

Download

Here’s where to download the yostupload program, which is implemented as a zsh (Z-Shell) script.


http://Yost.com/computers/yostupload/index.html - this page
2005-07-21 Created
2005-07-22 Modified
2005-07-27 Modified to make --rsync-args work
2005-07-20 rsync -H arg added
2005-08-02 2.0 now can download (rsync only)
2005-08-03 2.1 bug fix with root-level download
2005-08-03 2.2 allow multiple-file downloads
2005-08-13 added example .YostUploadRoot file
2005-12-14 2.3 added -l option
2006-02-13 2.4 make it silent if no -v option
2006-09-06 2.5 added rsync-args to .YostUploadRoot file
2007-01-21 2.6 added rsync -L arg for upload
2007-04-26 2.8 make the -l option cd on the server
2007-09-30 3.0 added -r rootFile, finishUp, and port
2007-10-05 3.1 added -f
2008-05-11 3.2 added -u; fixed bug with remote cd used by -l and finishUp
2008-05-15 3.3 fixed bug with remote cd used by -l and finishUp
2008-06-09 3.4 add --progress and such to the .YostUploadRoot example; fix bug with -l and no file arg
2008-06-09 3.5 fixed bug with -u arg not inserting a / between domain and path
2008-06-18 3.6 added -h to the standard rsync options for human-readable file size numbers in verbose mode
2008-06-27 3.7 use --progress instead of -v for verbose rsync upload and download
2008-06-29 3.8 url parameter now has to end with
2010-07-15 4.0 -f option renamed to -R; added -i, -o, -q options; -d will download multiple files
2011-07-21 4.1 tiny tweaks to the wording of usage help