Skip navigation.

Harold's Home

   Home
  
XML version of this site

PHP Scripts

Index
CLI fun
Mail on 404
HB-NS (NewsScript)

Downloads

Applescripts
APOD to Desktop
Dreamweaver Extensions

Stuff

Writings
Other stuff
Central Grinder

OOOk Default:

VJ stuff
VJ Tools
Bananas
Strippers
Sample Movies

News

Backing up
Pete of RasterWeb writes about the backup strategy he's employed. Fine stuff and something I've been doing for about a year and a half. (Cronnix is your friend in scheduling these kinds of scripts by the way.)

Here's an additional step I've taken lately.
It's a script that makes a rotating backup of three important directories in ~/Sites/www/ and archives them to ~/Documents/WebPages/Backup/auto-weekly/.
This script will archive certain directories and keep them available for a few weeks. This means that if I change something today and realise a week or two hence that this was a Really Really Bad Idea™ I still have the option to go back. It's a kind of version control without all the really technical stuff (believe me: real version control is much more involved).

Archives are named somewhat cryptically (with files named bla.0.gz, bla.1.gz etc.) but as the Finder can sort on date this is no big deal.

#!/bin/sh

cd /Users/harold/Sites/www;
tar cf /Users/harold/Documents/WebPages/Backup/auto-weekly/haroldbakker.tar haroldbakker.com;
tar cf /Users/harold/Documents/WebPages/Backup/auto-weekly/virtualpetrock.tar virtualpetrock.nl;
tar cf /Users/harold/Documents/WebPages/Backup/auto-weekly/blogscript.tar blogscript;

cd /Users/harold/Documents/WebPages/Backup/auto-weekly;

for i in haroldbakker.tar virtualpetrock.tar blogscript.tar; do
   if [ -f "${i}" ]; then
      if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
      if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
      if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
      if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
      if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
      if [ -f "${i}" ]; then mv -f "${i}" "${i}.0" && if [ -x /usr/bin/gzip ]; then gzip -9 "${i}.0"; fi; fi
   fi
done


If this script seems somehow familiar you've probably been looking at the periodic scripts included in Mac OS X, as they're a blatant rip-off.

In essence what this script does is create a backup of certain directories and archives them for a few weeks. This makes it easy to go back a week or four. For extra brownie points you will implement this yourself and backup to an external drive AND create monthly rotating backups too. (It doesn't have to use the same script.)

If you want to implement something like this I'd recommend doing a search for 'Mac OS X cron script tutorial' or something like that to find out more. If that doesn't help or confuses you (quite possible :-) ) just e-mail me and I'll do my best to help you out (or update this entry).

Just to point out the obvious though: the names 'harold', 'haroldbakker.com', 'virtualpetrock.nl', 'WebPages', 'auto-weekly' etc. are unlikely to be right for your system. A little thought on your part would be cool.

Show all items | Read all items

About, copyright, privacy and accessibility | Mail