A script to backup some key hidden system fiiles

Jun 22, '04 09:01:00AM

Contributed by: gdurr

Here a little shell script I wrote for easily switching from one Mac to another, or from one system to a new one. Sure, it is possible to use Carbon Copy Cloner or Apple's Software Restore, but these tools will copy all the stuff from one machine to another ... and sometimes, it is good to start with a clean state.

So you have to copy the data in /Users, but there are some other little configuration files that take a long time to customize. So here is a script to handle those items. What does it do? A folder is created, named with the current date. The Apache configuration files, the FTP files, the SystemConfiguration files, and the the crontab are copied to this folder.

How to launch it? Open Terminal, and type sh /path/of/the/script. Make sure you've made it executable first (chmod 755 script_name from within the script's directory).

#!/bin/sh
#	Allow switching from one mac to another
#	v0.1
#	g.durr.removethis@free.fr
#
cd "`dirname "$0"`"
mpath=`date`
mkdir "$mpath"
cd "$mpath"

#---------- APACHE ----------
mkdir http
cp /etc/httpd/httpd.conf ./http
cp /etc/httpd/mime.types ./http
cp -R /etc/httpd/users ./http

#---------- GENERAL ----------

cp -R /Library/Preferences/SystemConfiguration .
cp /etc/ftpusers .
cp /etc/hostconfig .

echo $PATH > ./PATH

#---------- CRONTAB ----------

mkdir crontab
cp -R /etc/crontab ./crontab/
crontab -l > ./crontab/`whoami`

#---------- INFO STARTUPITEM ----------
ls -lisa /Library/StartupItems/ > ./Info_startupitem
Let me know if anybody wants to improve it. It would be great if it was as complete as possible.

[robg adds: This is clearly not a complete backup script. However, it does do a nice job of copying over some of the "hidden" items one might miss in a system upgrade.]



October 26 2004 Update:
The author has sent in a much-revised version of the script. Due to the length of the script, I have uploaded it in a separate text file: bk_hidden.txt. Just copy and paste that into a new file in your fave Unix text editor, then follow the above directions to make it work.

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040329150916121