About Author

Hyon-Young Choi
blog: http://commani.net
twitter: @
github:

Engineering mind always..

  • Research Professor at Korea University
  • Internet, Mobile Network, Handover, QoS, ns-3, C++, Qt

About this Article

Date Released:
Sunday, October 27 2013 12:24 PM

Introduction

The tutorial in haroopress.com explains only how to publish to github.com with git. However, I have site with hosting account not with github.com. Hence, I should publish manually by using FTP.

While I am searching web, I found a page which is requesting the method to publish using rsync, but no solution appeared.

So, I tried to figure out how to publish using rsync with my hosting account. Here is the way I used.

Modified I have added --delete option to rsync.

Requirements

1. Hosting account

Important Hosting account MUST support ssh service.

And, you must know the target directory where the site pages are published into.

How to know the target directory

Login to the target hosting account

Using ssh:

$ ssh <account>@<domain>
Password:

My case:

login

Check the list of directory

My case: target directory is www.

check_target

Note The target directory name varies by hosting company, e.g., www, html, public, public_html, HomePage, etc.

2. Applications

  • rsync : synchronization application.
  • ssh : remote login in secure.

Action

0. Make up site pages

Skipped. Refer haroopress.com: new posting tutorial.

1. Generate site pages using haroopress engine

Simply run make gen

$ make gen

My case:

gen1

(many lines are omitted)

gen2

The site HTML sources are placed in _public directory.

2. Publish pages to the hosting account

Using rsync and ssh:

$ rsync -acvz -e ssh _public/ <account>@<domain>:<target_path>

Modified

-OR-

$ rsync -acvz --delete -e ssh _public/ <account>@<domain>:<target_path>

The options used above:

  • -a: archive
  • -c: detect file changes by checksum not by date and size
  • -v: verbose
  • -z: compress files while transfer
  • -e ssh: execute ssh for connecting remote site
  • Modified --delete: delete any files and directories in target path, which is not matched with source. Be Careful! YOU MAY LOSE SOME FILES IN THE SITE! If you do not know how this option works, backup whole files/directories of web-hosting account is recommended before use this option.

My case: <target_path> is www/.

publish1

(many lines are omitted)

publish2

Note Aboutchecksum option: rsync uses to detect files' changes by comparing date and size of files by default. However, haroopress always generates new files from source files after clearing the _publish directory. If file's date is used for detecting file change, rsync always puts all files including nothing changed. It causes unnecessary transfer. To solve this, we use checksum instead of file date and size. Checksum can distinguish the modified files among all newly generated files.

Modified Note About--delete option: If you change file or directory name of page, post, or slide in original data path (source/data/...) and publish with rsync without --delete option, the files or directories before change still exist in the hosting account. Hence, the site is massed up with garbage pages and exposes unwanted pages and old link to others. rsync with --delete option can provide you up-to-date site by removing old files. But if you have other pages nothing related to pages generated by haroopress, you MUST not use --delete option.

3. Ensure the publish completed

Ensure the site files are published successfully. Login again into hosting account, then check.

My case:

check

Automation

You can put the command into executable script file.

Create rsync_deploy.sh using any kind of editor.

The content of rsync_deploy.sh:

#!/bin/sh
rsync -acvz -e ssh _public/ <account>@<domain>:<path>

Modified

-OR-

#!/bin/sh
rsync -acvz --delete -e ssh _public/ <account>@<domain>:<path>

After create the file, give execution permission:

$ chmod +x rsync_deploy.sh

My case:

script

After that, just two commands are needed:

$ make gen
$ ./rsync_deploy.sh

blog comments powered by Disqus