download my resumeashley@mervyngraham.com

Ashley Mervyn Graham

rsnapshot Over a Network

Scenario

You can use Git to push changes of a website-or project-you manage. No changes (just an addition of a resource) are required to your local repository.

In essence we are setting up a remote git repository (which can be considered a good idea, in case your hard-drive takes a hit).

On The Server

Your remote repository will receive one change (or hook).

$ mkdir /srv/git/project && cd /srv/git/project
$ git init --bare

You can use any directory you wish, I just host my git repositores under /srv/git/

Then we create a hook: ne /srv/git/project/hooks/post-receive and insert the following inside that file:

#!/bin/sh
GIT_WORK_TREE=/var/www/project-deployed git checkout -f

Like above, where ever you serve up web-pages from.

Then make it executable.

chmod +x /srv/git/project/hooks/post-receive

Local Changes

You do have to do one thing locally (technically not a change to the repository; lets call it an update).

When you’re in your local git repository, just add a remote

$ git remote add deployed ssh://server.example.org/srv/git/project
		$ git push deployed +master:refs/heads/master
		

If you utilize a custom SSH port, the first command would look like:

$ git remote add deployed ssh://server.example.org:PORT/srv/git/project
		

Just remember to change :PORT to the actual port number your server uses.

Wrap-Up

Whenever you want to update your website, a simple: git push deployed will update your live site.