rsync-ing web pages

dilapidavid

Registered
I'm an OS X user who'd like to have a handy way to sync my web pages. I'm a total unix newbie, but I've caught onto the possibility of using rsync and/or rsyncx to do this.

Currently, I can use command-line sftp to post my stuff, but it seems I can only do one file at a time (right?).

Can someone tell me (step by step if possible) how to use rsync or rsyncx to accomplish this? (I can install, no prob. I've already installed rsyncx.)

When I use sftp, I enter:
>sftp username@server.school.edu
at which point it asks me to login.

Then I cd to my public_html directory, where I put my files. I'd love to be able to transfer and sync folders and files to this spot by entering a simple command or two. (I'm unfamiliar with writing/saving/using scripts, but if that's relevant here, let me know!)

Thanks for any help!
David

p.s.--I've read this hint and visited the macosxlabs site, but got lost and don't know how to improvise for my case.

http://www.macosxhints.com/article.php?story=20021023063424701&query=rsync

http://www.macosxlabs.org/documentation/script_archive/script_archive.html#rsyncx

p.p.s.--I just tried again using Rsyncx as best I could, and here's the (edited) output I got in the terminal:

me% time sudo rsync -a -e ssh "/Users/me/sites/itsc/" "username@server.school.edu:/public_html/" --nohfs --showtogo; exit
Password:
username@server.school.edu's password:
rsync: on remote machine: --showtogo: unknown option
rsync error: syntax or usage error (code 1) at main.c(842)
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)
1.130u 0.100s 0:43.52 2.8% 0+0k 4+1io 0pf+0w
logout
[Process completed]

p.p.p.s.--This is very close to the script found here:
http://www.macosxlabs.org/documentation/script_archive/scripts/rsyncx/5-netwrkbckupDataVolume.html
 
Okay . . . I've actually installed rsync using fink commander (which should help!). And now, from Rsyncx, I've tried again and gotten:

time rsync -a -e ssh "/Users/davidc/sites/itsc/" "username@server.school.edu:/public_html/" --showtogo; exit
rsync: --showtogo: unknown option
rsync error: syntax or usage error (code 1) at main.c(875)
0.010u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
logout
[Process completed]
 
Back on the ssh side di you every try using scp like scp -r public_html username@server.school.edu:~/public_html that will recursively copy the whole directory. You can also use * as a wild card with scp you just need to protect it from the shell with quotes liek this scp "*.html" username@server.school.edu:~/public_html/MyProject/pages

Now if you get rsync going it will have the advantage of only transmitting what has changed between the two locations. I always promeise myself I will learn the exact syntax but the scp command always finished before I take the time to look it up ;)

-Eric
 
Well . . . I took a stab. Again, I'm limited in my understanding of what I'm trying to do (ssh scp . . . or scp . . .). Here is my latest output. Pretty much the same as before! Why's "shotogo" getting an error??

me% time rsync -a -e ssh scp "/sites/public_html/" "username@server.school.edu:/public_html/" --delete --showtogo; exit
rsync: --showtogo: unknown option
rsync error: syntax or usage error (code 1) at main.c(875)
0.010u 0.010s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
logout
[Process completed]


me% time rsync -a -e scp "/sites/public_html/" "username@server.school.edu:/public_html/" --delete --showtogo; exit
rsync: --showtogo: unknown option
rsync error: syntax or usage error (code 1) at main.c(875)
0.000u 0.010s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
logout
[Process completed]
 
Okay, I believe I figured out that you *don't* want to install rsync after installing RsyncX. After uninstalling rsync and reinstalling RsyncX, I'm to a situation where it appears my machine is understanding the commands okay, but the server is not:

[mycomputer:~] me% time rsync -a -e ssh "sites/public_html/" "username@server.school.edu:public_html/" --nohfs --delete --showtogo; exit
username@server.school.edu's password:
rsync: on remote machine: --showtogo: unknown option
rsync error: syntax or usage error (code 1) at main.c(842)
rsync: connection unexpectedly closed (0 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(150)
0.080u 0.030s 0:16.61 0.6% 0+0k 2+0io 0pf+0w
logout
[Process completed]
 
After three days and consulting several people I lucked into discovering that it was faulty syntax. (I'm trying to speak a language I don't understand!) The little slashes at the very end make all the difference. A slash at the end of the source path says "sync everything in this folder," whereas the absence of a slash says "sync this folder and its contents." But for the destination, you want to name the folder to sync *into*, with *no slash* after it--that last slash was screwing everything up.

Let that be a lesson . . . :)

NO!
rsync -v -ae ssh "/Users/me/sites/public_html/" "username@server.school.edu:public_html/" --delete --progress

YES!
rsync -v -ae ssh "/Users/me/sites/public_html" "username@server.school.edu:" --delete --progress

ALSO YES!
rsync -v -ae ssh "/Users/me/sites/public_html/" "username@server.school.edu:public_html" --delete --progress
 
Back
Top