#!/bin/bash windows_device=/dev/sda1 default_image_file="/home/windows/user/Documents and Settings/Admin/My Documents/Backups/sda1.ntfsclone.gz" image_file="${1:-"$default_image_file"}" echo " You are about to back up the Windows system partition (C:) to the backup file $image_file. This will let you, at some later date, restore Windows (including all installed software) to the exact state it is in right now, while keeping your own files and folders (stored on D:, the User partition) intact." if test -f "$image_file" -a ! -L "$image_file" then echo " However, since you are about to over-write an existing version of that backup file, you will lose the ability to restore Windows to the state it was in as of $(date +%c -d @$(stat -c %Y "$image_file"))." fi read -p " Is that what you want to do? " reply reply="$(echo "$reply" | tr A-Z a-z)" if [ "${reply:0:1}" = "y" ] then mnt=/tmp/backup-windows-$$ sudo sh -c " umount '$windows_device' mkdir $mnt mount '$windows_device' $mnt rm -f $mnt/pagefile.sys $mnt/hiberfil.sys sync umount '$windows_device' rmdir $mnt rm '$image_file' ntfsclone --save-image -o - '$windows_device' | gzip -9 >'$image_file' mount -a " read -p " Press Enter: " fi