Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 29. marec 2024

Súbor: [Platon] / scripts / shell / Windows-backup / WindowsBackup.sh (stiahnutie)

Revízia 1.3, Sun Jan 9 20:41:19 2005 UTC (19 years, 2 months ago) by rajo


Zmeny od 1.2: +18 -2 [lines]

Added BIG FAT WARNING

#!/bin/sh

##
## Script for making installation backup of Windows :-)
##

# XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
#
# BIG FAT WARNING !!
#
# Do not use this script for backups of live filesystems
# (currently mounted od used)
#
# For backup od live filesystems use another technologies:
#  - filesystem snapshots
#  - disk mirroring (RAID1, RAID5, RAID6, RAID10)
#  - simple tar/zip/rar/cp/cpio
#  - other techniquies
#
# XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX


#
# Developed by Lubomir Host <rajo AT platon.sk>
# Copyright (c) 2003-2005 Platon SDG
# Licensed under terms of GNU General Public License.
# All rights reserved.
#

# $Platon: scripts/shell/Windows-backup/WindowsBackup.sh,v 1.2 2004/03/16 19:51:05 rajo Exp $

## 1. Install Windows with all needed programs
## 2. Configure all programs, windows, etc.
## 3. Defragment this drive and make few reboots -- 
##    your setting will converge to stable ... :-)
## 4. Run this script
## 5. Reinstallation of Windows is simple:
##
##    gunzip -c Windows-image-backup.img.gz | dd of=/dev/hda1
##
##    It takes aprox. 8 min:
##              1.5 GB partition, 450 MB used,
##              Windows image size: 217668033 bytes ~ 200 MB
##              processor: 500 MHz Pentium,
##              disk:      WDC WD84AA, ATA DISK drive - 8.4 GB,
##                         DMA, primary master
##              cdrom:     E5SA CDROM, ATAPI CD/DVD-ROM drive,
##                         44x speed, primary slave

OUTPUT_DIR="/d/Windows-image-backup-`date '+%y-%m-%d'`"
IMAGE="Windows-image-backup.img.bz2"
MOUNT_POINT="/c"
DEVICE="/dev/hda1"

createBackup()
{ # {{{
    mkdir -p "$OUTPUT_DIR" || exit 1
    cd "$OUTPUT_DIR" || exit 1
    
    # image is smaller if you cleare entire disk
    echo "`date` -- Clearing unused filesystem blocks"
    dd if=/dev/zero of=$MOUNT_POINT/zero
    rm -f $MOUNT_POINT/zero
    
    echo "`date` -- Remounting $MOUNT_POINT read-only"
    mount -o remount,ro $MOUNT_POINT || exit 1
    
    echo "`date` -- Creating list of files"
    find "$MOUNT_POINT" -printf "%p\t%s\t%a\n" \
        | sort > files \
        || exit 1
    
    echo "`date` -- Creating md5sums of files"
    find "$MOUNT_POINT" -type f -exec md5sum {} \; > md5sums \
        || exit 1
    
    echo "`date` -- Unmounting $MOUNT_POINT"
    umount "$MOUNT_POINT" || exit 1
    
    echo "`date` -- Creating Windows image ..."
    dd "if=$DEVICE" | bzip2 --best -c > "$IMAGE" || exit 1
    
    echo "`date` -- Mounting $MOUNT_POINT back"
    mount "$MOUNT_POINT" && echo "... OK"
    
    echo "`date` -- Calculating md5sum of image"
    for i in files md5sums "$IMAGE"; do
        md5sum "$i" > "$i.md5sum"
    done
} # }}}

createBackup;

# vim: ts=4
# vim600: fdm=marker fdl=0 fdc=3


Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok