TITLE
    Mac OS X Server: UFS Backup Script
Article ID:
Created:
Modified:
60145
3/16/99
5/29/00

TOPIC

    The provided script allows you to backup your UFS file systems on a Mac OS X Server computer. It attempts to filter out any file that is unmodified from your system installation. It does this by comparing the system's disk contents with the package receipts left by the Installer.app.


DISCUSSION

    This process takes a fair amount of time to examine the hard disk to determine what to write on the tape.

    Limitations
    • You must be logged in as the System Administrator to use the script.
    • This script does not have any incremental backup functionality.
    • Backups spanning multiple tapes has not been tested.

    Steps to Create a backup

    To create a backup archive do the following:

    1. Make sure you are logged in as the System Administrator (root).
    2. Start Terminal.app to get a BSD command shell window.
    3. Use a text editor to create the backup script below. You only need to do this step the first time you wish to make a backup (or when a new backup script is released). Save the script as /usr/local/bin/makebackup and then make it executable ( chmod 754 /usr/local/bin/makebackup ).

    #! /bin/sh
    # simple backup script to copy all files listed in the system package receipts
    # and added files to the specified destination
    #
    # usage: makebackup <destination>
    #    where destination is typacally a tape backup device
    #    e.g. makebackup /dev/rst0
    #
    # This is intended to be run only by the super-user
    #
    if [ `whoami` != root ]
    then
    echo "$0 is intended to be run by the System Administrator"
    exit 1
    fi


    if [ "x$1" = "x" ]
    then
    echo usage: "$0 <destination>"
    exit 1
    fi


    #
    # remove modified files that are unnecessary to backup
    # The list is:
    #    /Network - network data residing on another machine
    #    /private/Network - network data residing on another machine
    #    /private/dev - special device files created at boot time
    #    /private/var/run - runtime data create at boot time
    #    /private/tmp - temporary directory cleaned up at boot time
    #    AppKit and Foundation documentation is tweaked during post_install
    #    /System/Library/Java diretiry is tweaked during post_install
    #    /private/Devices - directory is mode changed during post_install
    #    /Local/Library/Receipts - these are the package recepits and shouldn't be restored
    #    precomp header files (*.p)
    #    other misc. things
    showmods -t --find-added | awk '{print $1}' | \
    sed -e '/^\/Network\//d' -e '/^\/private\/dev\//d' \
    -e '/\/private\/dev$/d' \
    -e '/^\/private\/var\/run\//d' -e '/^\/private\/tmp\//d' \
    -e '/^\/private\/var\/run$/d' -e '/^\/private\/tmp$/d' \
    -e '/^\/private\/Network\//d' \
    -e '/^\/private\/Network$/d' \

    -e '/^\/System\/Library\/Frameworks\/AppKit.framework\/Versions\/C\/Resources\/English.lproj\/Documentation\/Reference\//d' \
    -e '/^\/System\/Library\/Frameworks\/Foundation.framework\/Versions\/C\/Resources\/English.lproj\/Documentation\/Reference\//d' \
    -e '/^\/System\/Library\/Java$/d' \
    -e '/^\/private\/Devices$/d' \
    -e '/^\/Local\/Library\/Receipts\//d' \
    -e '/^\/System\/Library\/Frameworks\/.*\.p$/d' \
    -e '/^\/System\/Library\/CoreServices\//d' \
    -e '/^\/System\/Library\/Fonts\/.default.fcache$/d' \
    -e '/^\/System\/Library\/Frameworks\/System.framework\/Resources$/d' \
    -e '/^\/System\/Library\/Frameworks\/System.framework\/Versions\/Current$/d' \
    -e '/^\/System\/Library\/PrivateFrameworks\/Keyboard.framework\/Resources$/d' \
    -e '/^\/System\/Library\/PrivateFrameworks\/Keyboard.framework\/Versions\/Current$/d' \
    -e '/^\/private\/var\/vm\//d' \
    -e '/^\/Local\/Applications\/Internet\/OmniWeb.app/d' \
    | pax -w -v -x cpio -f $1


    4. Determine the BSD device name for your tape drive (generally /dev/rst0).
    5. Run the backup script using the following command:
    /usr/local/bin/makebackup tapeDevice
    Where tapeDevice is the device name of your tape drive.

    The makebackup script creates a cpio format archive. For more information on the cpio tape format please refer to the BSD manual pages for cpio(1) or pax(1). You can view these manual pages by using the following commands from a command line shell:
    man cpio
    man pax

    Steps to Restore a Backup

    To examine the list of files on the tape archive use the command:
    pax -v -f tapeDevice

    To restore files use the command:
    pax -r -v -f tapeDevice <list of files to restore>
    Where <list of files to restore> is a space separated list of file paths to extract from the tape archive. You must specify full file paths to restore and if the file paths contain spaces or other non-alphanumeric characters such as "*", you must enclose the file paths with single quotes (').

    If you wish to restore all files from the backup, do not specify a list of files to restore.

Document Information
Product Area: Mac OS System Software
Category: Mac OS X Server
Sub Category: General Topics

Copyright © 2000 Apple Computer, Inc. All rights reserved.