dan rasmussen . org

web design, tech/creative services, and fun

danrasmussen.org > Library > Site Build Scripts

Site Build Scripts

Here are some shell scripts I use to build my website. Most of them require rsync, which is probably already installed on your Linux-based system. They've saved me a lot of typing! Maybe they will come in handy for you, too.


Some of these scripts make use of special text files. These files are: exclude_list_rsync and include_list_rsync. They contain lists of filenames, one per line. In exclude_list_rsync, put a list of files you do not want to be uploaded to the server. Here is a sample "exclude" file:

exclude_list_rsync

  1. todo/
  2. *svn*
  3. *~
  4. *.sh

It contains: 1) a directory called todo/, 2) a wildcard for subversion files, 3) backup files, and 4) shell scripts. Any other files that clutter up your server, or pose security risks, should also be added.

supload.sh

This script uploads a single file to your server. Usage: ./supload.sh (file)

  1. #!/bin/sh
  2. rsync -rRvu $1 user@host.com:folder/

upload_dry.sh

This shell script tells you what files rsync wants to upload - files that don't exist on the remote destination or are newer on your local system. Files in exclude_list_rsync (a text file with one filename per line) It saves a list of those files in the file include_list_rsync. This file could come in handy in conjunction with the next script. Read on.

  1. #!/bin/sh
  2. rsync -rRvun . --exclude-from="exclude_list_rsync" user@host.com:folder > include_list_rsync
  3. cat include_list_rsync

upload_selected.sh

This script works well with upload_dry script above. Edit it to your liking. Remove all the lines from it that aren't filenames (such as the output from rsync left by running upload_dry). Then, ./upload_selected.sh sends only the files listed in include_list_rsync to the server.

  1. #!/bin/sh
  2. # Upload only the files listed in include_list_rsync
  3. rsync -rRvu `cat include_list_rsync` user@host.com:folder

clean.sh

This clears up all those pesky backup files (the ones with ~ in the name) cluttering the development folder. Make sure you don't need them first!

  1. #!/bin/sh
  2. find . -name '*.*~'
  3. echo Removing backups..
  4. find . -name '*.*~' -exec rm {} \;

upload_dev.sh

This script is what I use to pump files to a test area - to make sure they work, get opinions, etc.

  1. #!/bin/sh
  2. # Upload to development area for testing, validation, demos, etc.
  3. rsync -rvu --delete . --exclude-from="exclude_list_rsync" user@host.com:folder/dev

upload.sh

Uploads everything to the server.

  1. #!/bin/sh
  2. rsync -rvu . --exclude-from="exclude_list_rsync" user@host.com:folder

If these make your life better in some way, I'd be happy to hear about it. Oh, and I've got a wish list in case you're loaded.

Page last updated: April 28, 2014.


  • Home
  • Software
  • Library
  • Portfolio
  • Resume
  • Services
  • Contact


choose a style >> : / BlueOrange / Night Vision / Grayscale / Sami / No Style /

This is the personal website of Dan Rasmussen.

© 2002-2014 Dan Rasmussen