Code Sample |
#!/bin/bash #backup script backup() { echo " " echo " This process can take up to an hour" echo " " echo "System will reboot to enter automatic backup operations." echo "If you started this by mistake, you have 10 seconds" echo " to cancel this by pressing CTRL-C." sleep 10 sudo cp /boot/grub/menu.lst_backupmode /boot/grub/menu.lst sudo mount /dev/hda3 /mnt/hda3 2> /dev/null sudo cp /mnt/hda3/opt/bootlocal.sh_backupmode /mnt/hda3/opt/bootlocal.sh echo "Backup Mode boot process initialized" sleep 10 echo "BEGINNING" sleep 1 sudo reboot } echo " WELCOME TO THE SYSTEM BACKUP UTILITY" echo " " echo " This utility is designed to backup your system so that" echo " in the event of a system malfunction, you can restore to" echo " this point." echo " " echo " Everything will be backed up. Even documents and personal" echo " files. It is wise to do this regularly, perhaps once a week." echo " " echo " The backup process is fully automatic, and will take almost an hour" echo " so it is a good idea to start the backup just before bed, or when" echo " you know you will not be needing your machine for a little while." echo " " echo " PLEASE SAVE ALL OPEN FILES BEFORE CONTINUING BACKUP!!!" echo " " echo "Press ENTER to continue..." read throwaway clear echo "Would you like to reboot and run backup operations?" echo "1. YES" echo "2. NO" read answer case $answer in 1) backup ;; *) exit esac done |
Code Sample |
sudo cp /boot/grub/menu.lst_backupmode /boot/grub/menu.lst |
Code Sample |
sudo mount /dev/hda3 /mnt/hda3 2> /dev/null |
Code Sample |
sudo cp /mnt/hda3/opt/bootlocal.sh_backupmode /mnt/hda3/opt/bootlocal.sh |
Code Sample |
sudo cp /mnt/hda3/opt/bootlocal.sh_backupmode /mnt/hda3/opt/bootlocal.sh |
Code Sample |
sudo cp /mnt/hda3/opt/bootlocal.sh_restoremode /mnt/hda3/opt/bootlocal.sh |
Code Sample |
#!/bin/bash # Backup Script #make directory and mount partition hda1 mkdir hda1 2> /dev/null mount /dev/hda1 /hda1 echo "Main partition mounted..." #first thing is to restore the normal menu.lst on hda1 so that in #the event of a reboot, it will boot to the normal system sudo cp /hda1/boot/grub/menu.lst_normal /hda1/boot/grub/menu.lst echo "reboot synced to main" wait 2 clear echo " About to begin backup operations." echo " Once this is started do not turn off your machine." echo "Performing BACKUP Operations..." echo "This can take up to an hour, please be patient." echo " " sleep 3 echo " " echo "Deleting previous backup file." echo " " echo " " #delete the old backup file rm -f /hda1backup.tar.gz echo "Building backup file /hda3/hda1backup.tar.gz" echo " " echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" #backup hda1 to the file hda1backup.tar.gz tar -czvpsf /hda1backup.tar.gz hda1 clear echo " " echo "Operating System on hda1 is now backed up to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " #once that is complete, change bootlocal.sh to something else # bootlocal.sh_reboot has the system automatically reboot before # it gets all the way booted up so the hda3 system can't be messed with cp /opt/bootlocal.sh_reboot /opt/bootlocal.sh echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 #reboot to the main system reboot |
Code Sample |
#!/bin/bash # Restoration Script mkdir hda1 2> /dev/null mount /dev/hda1 /hda1 echo "Main partition mounted..." sudo cp /hda1/boot/grub/menu.lst_normal /hda1/boot/grub/menu.lst echo "reboot synced to main" wait 2 clear echo " " echo " About to begin restoration operations." echo " Once this is started do not turn off your machine." echo "Performing RESTORE Operations..." echo "This takes about half an hour, please be patient." echo " " sleep 3 echo " " echo " " echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" #this is the only line that is really any different from backup.sh # it unpacks hda1backup.tar.gz to the hda1 partition. tar -xvzf /hda1backup.tar.gz -C / clear echo " " echo "Operating System on hda1 is now restored from to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " cp /opt/bootlocal.sh_reboot /opt/bootlocal.sh echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 reboot |
Code Sample |
sudo su mkdir /hda3 umount /dev/hda3 mount /dev/hda3 /hda3 cd / tar -cvzpsf /hda3backup.tar.gz hda3 |
Code Sample |
sudo dd if=/dev/hda of=/MBRbackup.bin bs=1 count=512 |
Code Sample |
sudo su mkdir /hdb1 mount /dev/hdb1 /hdb1 cd /hdb1 #note that from here on out everything is done from /hdb1 directory mkdir source newcd newcd/KNOPPIX cp -Rp /cdrom/boot newcd cp -Rp /cdrom/lost+found newcd cp -Rp /cdrom/index.html newcd cp -Rp /KNOPPIX/* source cp -Rp /KNOPPIX/.bash_profile source |
Code Sample |
sudo /KNOPPIX/backup/CDbackup.sh |
Code Sample |
#!/KNOPPIX/bin/bash # CD Restoration Script initialize() { title() { clear echo " " echo " Roslins Restore Disk" echo " ver. 1.2 " echo " " echo " " echo " " echo " " echo " by Jeff Smith " echo " straightshootincomputin@yahoo.com " echo " " echo " " echo " Press Enter to continue..." read throwaway } # this is the text that pops up when -=More Information=- # is selected from the menu. information() { clear echo " " echo " Hello, and welcome to Roslins Restore Disk! " echo " " echo " This disk will help you to restore your laptop" echo " to working condition with little hassel." echo " " echo " There are two options on the main menu for " echo " restoring. It is best to try Option 1 first and see" echo " if that gives you the results you want." echo " " echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 1 - Restore Last Backup" echo " Option 1 restores from the last backup you made" echo " using the BACKUP feature located in the right-click" echo " menu on the desktop." echo " " echo " If possible, you should use the RESTORE feature from" echo " that menu instead of using this disk." echo " " echo " Use Option 1 in the event that you cannot get to that " echo " feature in the right-click menu." echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 2 - Full Restoration" echo " Option 2 is for when you have really messed things up." echo " " echo " Option 2 will delete all information on your laptop" echo " and restore it to the way it was when you first got it." echo " " echo " All personal files and downloads will be gone" echo " but you will have a working system again." echo " " echo " Use Option 2 if Option 1 does not fix the problem." echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 2 - Full Restoration (continued)" echo " If Option 2 does not fix the problem, then you may" echo " need to first restore the Master Boot Record (MBR)," echo " which is Option 4. Then come back after rebooting " echo " and try Option 2 again, and it should work fine." echo " " echo " If none of this works, you may have a faulty" echo " harddrive." echo " " echo " " echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 3 - Make a new backup" echo " Option 3 will backup your main installation on hda1" echo " " echo " If you have lost the ability to backup via your right-click" echo " menu, you may not want to make this backup because doing" echo " so will lock in the changes you've made to the right-click menu." echo " Once you've backed up those changes, your only way of " echo " putting that option back is by doing the full restoration " echo " (Option 2) from this disk." echo " You will still be able to restore from this new backup" echo " by using this CD if you do not want the right-click option available" echo " Press Enter to continue..." read throwaway } mount_drives() { mkdir /hda1 mkdir /hda3 echo "Checking Filesystems" fsck /dev/hda1 fsck /dev/hda3 sleep 2 clear echo "Mounting partitions" sudo mount /dev/hda1 /hda1 sudo mount /dev/hda3 /hda3 sleep 2 } #this is function to reboot the machine reboot_to_hd() { echo " " echo " " echo " Please press ENTER to reboot." read throwaway echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 reboot } # this is a function to make a new backup file # on the partition hda3 backup_to_hda3() { clear echo " " echo "Performing Backup Operations..." echo "This can take up to an hour, please be patient." sleep 3 mount_drives cd / echo "Deleting previous backup file." rm -f /hda3/hda1backup.tar.gz echo "Building backup file /hda3/hda1backup.tar.gz" echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" tar -cvzpsf hda3/hda1backup.tar.gz /hda1 clear echo " " echo "Operating System on hda1 is now backed up to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " echo "You can restore this backup by using the RESTORE option" echo "located in the right-click menu, or by selecting Option 1" echo "from this disk." reboot_to_hd } # this is a function to restore from a backup file # that is located on the partition hda3 restore_from_hda3() { clear echo " " echo "Restoring from Harddrive backup" echo "This will take a while, please be patient." echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" sleep 3 mount_drives cd /hda3 tar -xvzf hda1backup.tar.gz -C / clear echo " " echo "Operating System on hda1 is now restored from" echo "hda1backup.tar.gz on hda3." reboot_to_hd } warning() { clear echo " " echo " Please note that this will delete everything on the drive" echo " before restoring from the original backup file." echo " " echo " Use this only if Option 1 does not work." echo " " echo "This machine will be reset to the state it was in when" echo " you received it." echo " Are you sure you want to do this?" echo " 1. Yes" echo " 2. No" echo "Enter your choice: " read warningchoice case $warningchoice in 1) restore_from_permanent ;; *) echo "Returning to main menu"; sleep 2 esac } # this is a function to restore the MBR # from a backup file on the CD restore_mbr() { clear echo " " echo "Restoring Master Boot Record (MBR)" dd if=/KNOPPIX/backup/MBRbackup.bin of=/dev/hda bs=1 count=512 echo " " echo "Master Boot Record restored." reboot_to_hd } restore_from_permanent() { clear echo "Will shortly begin restoring from permanent backup file " echo "located on this disk." echo " " echo "This will take a while, please be patient." echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" sleep 3 echo "Format hda1" mkfs.ext2 /dev/hda1 clear echo "Format hda3" mkfs.ext2 /dev/hda3 clear echo "Partitions formatted." mount_drives clear echo "Beginning hda1 restore" cd /KNOPPIX/backup tar -xvzf hda1backup.tar.gz -C / clear echo "hda1 restore complete." sleep 5 echo "Beginning hda3 restore" tar -xvzf hda3backup.tar.gz -C / clear echo "hda3 restore complete." sleep 5 clear echo "Copying hda1backup.tar.gz to hda3" cp /KNOPPIX/backup/hda1backup.tar.gz /hda3/hda1backup.tar.gz sleep 2 clear echo "Unmounting partitions" sudo umount /dev/hda1 sudo umount /dev/hda3 echo " " echo "Restoration Complete." reboot_to_hd } interrupt_trapper() { echo "Cannot exit script this way." echo "To exit, select Option 5 or Option 6" echo "from the Main Menu" } menu() { trap interrupt_trapper INT clear echo " MAIN MENU " echo " " echo "Choose from one of the options below to begin" echo " " echo "1. Restore Operating System from Harddrive Backup" echo "2. Do a Complete Restore from Backup on this disk" echo "3. Make a new backup of the system." echo "4. Restore MBR" echo "5. REBOOT" echo "6. Exit to Live session" echo " " echo " For more information on the presented options," echo " just press ENTER without any number." echo " " echo "If you're ready to begin, just type the" echo "number of your choice, and then press ENTER" read choice case $choice in 1) restore_from_hda3 ;; 2) warning ;; 3) backup_to_hda3 ;; 4) restore_mbr ;; 5) reboot_to_hd ;; 6) exit ;; *) information esac } } #below is the main flow of the script #everything else is a function. initialize title while :; do menu done |
Code Sample |
mkisofs -R source | create_compressed_fs – 65536 > newcd/KNOPPIX/KNOPPIX |
Code Sample |
mkisofs -no-pad -l -r -J -no-emul-boot -boot-load-size 4 –boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -hide-rr-moved -o mydsl.iso newcd |
Code Sample |
#!/bin/bash #backup script backup() { echo " " echo " This process can take up to an hour" echo " " echo "System will reboot to enter automatic backup operations." echo "If you started this by mistake, you have 10 seconds" echo " to cancel this by pressing CTRL-C." sleep 10 sudo cp /boot/grub/menu.lst_backupmode /boot/grub/menu.lst sudo mount /dev/hda3 /mnt/hda3 2> /dev/null sudo cp /mnt/hda3/opt/bootlocal.sh_backupmode /mnt/hda3/opt/bootlocal.sh echo "Backup Mode boot process initialized" sleep 10 echo "BEGINNING" sleep 1 sudo reboot } echo " WELCOME TO THE SYSTEM BACKUP UTILITY" echo " " echo " This utility is designed to backup your system so that" echo " in the event of a system malfunction, you can restore to" echo " this point." echo " " echo " Everything will be backed up. Even documents and personal" echo " files. It is wise to do this regularly, perhaps once a week." echo " " echo " The backup process is fully automatic, and will take almost an hour" echo " so it is a good idea to start the backup just before bed, or when" echo " you know you will not be needing your machine for a little while." echo " " echo " PLEASE SAVE ALL OPEN FILES BEFORE CONTINUING BACKUP!!!" echo " " echo "Press ENTER to continue..." read throwaway clear echo "Would you like to reboot and run backup operations?" echo "1. YES" echo "2. NO" read answer case $answer in 1) backup ;; *) exit esac done |
Code Sample |
#!/bin/bash #restore script restore() { clear echo " " echo " " echo " If you started this by mistake, you have 15 seconds" echo " to cancel this by pressing CTRL-C." echo " " echo " This process takes about half an hour" echo " " echo " Unless you cancel, the system will reboot and " echo " begin automatic restore operations." sleep 15 sudo cp /boot/grub/menu.lst_backupmode /boot/grub/menu.lst sudo mount /dev/hda3 /mnt/hda3 2> /dev/null sudo cp /mnt/hda3/opt/bootlocal.sh_restoremode /mnt/hda3/opt/bootlocal.sh echo "Restore Mode boot process initialized" sleep 2 echo "BEGINNING" sleep 1 sudo reboot } clear echo " WELCOME TO THE SYSTEM RESTORE UTILITY" echo " " echo " This utility is designed to restore your system to the" echo " state it was in when the last backup was made" echo " " echo " Everything will be restored. Even documents you may have deleted" echo " since then. If you have messed this system up, this is the easiest" echo " way to make it work again." echo " " echo " The restore process is fully automatic, and will take about half an hour" echo " so it is a good idea to start the process just before bed, or when" echo " you know you will not be needing your machine for a little while." echo " " echo " " echo "Press ENTER to continue..." read throwaway clear echo "Would you like to reboot and run restore operations?" echo "1. YES" echo "2. NO" read answer case $answer in 1) restore ;; *) exit esac done |
Code Sample |
default 0 hiddenmenu timeout 3 title Boot into Linux kernel /boot/linux24 root=/dev/hda1 quiet vga=normal dma nofstab norestore noscsi frugal title Backup Mode kernel /boot/linux24 root=/dev/hda3 quiet vga=normal dma nofstab norestore noscsi frugal title Repair Mode kernel /boot/linux24 root=/dev/hda1 quiet vga=normal noacpi noapm noscsi nodma frugal 2 base |
Code Sample |
default 0 hiddenmenu timeout 3 title Backup Mode kernel /boot/linux24 root=/dev/hda3 quiet vga=normal dma nofstab norestore noscsi frugal title Boot into Linux kernel /boot/linux24 root=/dev/hda1 quiet vga=normal dma nofstab norestore noscsi frugal title Repair Mode kernel /boot/linux24 root=/dev/hda1 quiet vga=normal noacpi noapm noscsi nodma frugal 2 base |
Code Sample |
#!/bin/bash # put other system startup command here clear echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " Starting BACKUP script..." echo " " echo " " echo " " echo " " echo " Programmed by Jeff Smith " echo " straightshootincomputin@yahoo.com " sleep 2 sudo /backup/backup.sh /sbin/syslogd |
Code Sample |
#!/bin/bash # put other system startup command here clear echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " " echo " Starting RESTORE script..." echo " " echo " " echo " " echo " " echo " Programmed by Jeff Smith " echo " straightshootincomputin@yahoo.com " sleep 2 sudo /backup/restore.sh /sbin/syslogd |
Code Sample |
#!/bin/bash # put other system startup command here clear echo " " echo " " echo " " echo " " echo " " echo " Do not enter this system unless it is via the Backup/Restore " echo " options available on the main installation." echo " " echo " corrupting this installation would make it impossible for you " echo " to use the backup/restore functions " echo " if you've lost the ability to restore via the right-click" echo " menu, please use the Restore Disk and select Option 1" echo " to restore the last backup you have made." reboot |
Code Sample |
#!/bin/bash # Backup Script mkdir hda1 2> /dev/null mkdir hda3 2> /dev/null mount /dev/hda1 /hda1 echo "Main partition mounted..." sudo cp /hda1/boot/grub/menu.lst_normal /hda1/boot/grub/menu.lst echo "reboot synced to main" wait 2 clear echo " About to begin backup operations." echo " Once this is started do not turn off your machine." echo " Performing BACKUP Operations..." echo "This can take up to an hour, please be patient." echo " " sleep 3 echo " " echo "Deleting previous backup file." echo " " echo " " rm -f /hda1backup.tar.gz echo "Building backup file /hda3/hda1backup.tar.gz" echo " " echo " This takes about an hour" echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" tar -czvpsf /hda1backup.tar.gz hda1 clear echo " " echo "Operating System on hda1 is now backed up to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " cp /opt/bootlocal.sh_reboot /opt/bootlocal.sh echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 reboot |
Code Sample |
#!/bin/bash # Restoration Script mkdir hda1 2> /dev/null mount /dev/hda1 /hda1 echo "Main partition mounted..." sudo cp /hda1/boot/grub/menu.lst_normal /hda1/boot/grub/menu.lst echo "reboot synced to main" wait 2 clear echo " " echo " About to begin restoration operations." echo " Once this is started do not turn off your machine." echo " Performing RESTORE Operations..." echo "This takes about half an hour, please be patient." echo " " sleep 3 echo " " echo " " echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" tar -xvzf /hda1backup.tar.gz -C / clear echo " " echo "Operating System on hda1 is now restored from to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " cp /opt/bootlocal.sh_reboot /opt/bootlocal.sh echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 reboot |
Code Sample |
sudo /KNOPPIX/backup/CDbackup.sh |
Code Sample |
#!/KNOPPIX/bin/bash # CD Restoration Script initialize() { title() { clear echo " " echo " Roslins Restore Disk" echo " ver. 1.2 " echo " " echo " " echo " " echo " " echo " by Jeff Smith " echo " straightshootincomputin@yahoo.com " echo " " echo " " echo " Press Enter to continue..." read throwaway } # this is the text that pops up when -=More Information=- # is selected from the menu. information() { clear echo " " echo " Hello, and welcome to Roslins Restore Disk! " echo " " echo " This disk will help you to restore your computer" echo " to working condition with little hassel." echo " " echo " There are two options on the main menu for " echo " restoring. It is best to try Option 1 first and see" echo " if that gives you the results you want." echo " " echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 1 - Restore Last Backup" echo " Option 1 restores from the last backup you made" echo " using the BACKUP feature located in the right-click" echo " menu on the desktop." echo " " echo " If possible, you should use the RESTORE feature from" echo " that menu instead of using this disk." echo " " echo " Use Option 1 in the event that you cannot get to that " echo " feature in the right-click menu." echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 2 - Full Restoration" echo " Option 2 is for when you have really messed things up." echo " " echo " Option 2 will delete all information on your laptop" echo " and restore it to the way it was when you first got it." echo " " echo " All personal files and downloads will be gone" echo " but you will have a working system again." echo " " echo " Use Option 2 if Option 1 does not fix the problem." echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 2 - Full Restoration (continued)" echo " If Option 2 does not fix the problem, then you may" echo " need to first restore the Master Boot Record (MBR)," echo " which is Option 4. Then come back after rebooting " echo " and try Option 2 again, and it should work fine." echo " " echo " If none of this works, you may have a faulty" echo " harddrive." echo " " echo " WARNING!" echo " NEVER USE OPTION 4 ON ANY MACHINE BUT THE ONE" echo " THAT THIS DISK IS MADE FOR. " echo " DOING SO COULD CAUSE PERMANENT DAMAGE TO IT." echo " " echo " Press Enter to continue..." read throwaway clear echo "Option 3 - Make a new backup" echo " Option 3 will backup your main installation on hda1" echo " " echo " If you have lost the ability to backup via your right-click" echo " menu, you may not want to make this backup because doing" echo " so will lock in the changes you've made to the right-click menu." echo " Once you've backed up those changes, your only way of " echo " putting that option back is by doing the full restoration " echo " (Option 2) from this disk." echo " You will still be able to restore from this new backup" echo " by using this CD if you do not want the right-click option available" echo " Press Enter to continue..." read throwaway } mount_drives() { mkdir /hda1 mkdir /hda3 echo "Checking Filesystems" fsck /dev/hda1 fsck /dev/hda3 sleep 2 clear echo "Mounting partitions" sudo mount /dev/hda1 /hda1 sudo mount /dev/hda3 /hda3 sleep 2 } #this is function to reboot the machine reboot_to_hd() { echo " " echo " " echo " Please press ENTER to reboot." read throwaway echo "System will begin reboot in 5 seconds" sleep 4 echo "Rebooting now!" sleep 1 reboot } # this is a function to make a new backup file # on the partition hda3 backup_to_hda3() { clear echo " " echo "Performing Backup Operations..." echo "This can take up to an hour, please be patient." sleep 3 mount_drives cd / echo "Deleting previous backup file." rm -f /hda3/hda1backup.tar.gz echo "Building backup file /hda3/hda1backup.tar.gz" echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" tar -cvzpsf hda3/hda1backup.tar.gz /hda1 clear echo " " echo "Operating System on hda1 is now backed up to the file" echo "hda1backup.tar.gz on the backup partition (hda3)." echo " " echo "You can restore this backup by using the RESTORE option" echo "located in the right-click menu, or by selecting Option 1" echo "from this disk." reboot_to_hd } # this is a function to restore from a backup file # that is located on the partition hda3 restore_from_hda3() { clear echo " " echo "Restoring from Harddrive backup" echo "This will take a while, please be patient." echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" sleep 3 mount_drives cd /hda3 tar -xvzf hda1backup.tar.gz -C / clear echo " " echo "Operating System on hda1 is now restored from" echo "hda1backup.tar.gz on hda3." reboot_to_hd } warning() { clear echo " " echo " Please note that this will delete everything on the drive" echo " before restoring from the original backup file." echo " " echo " Use this only if Option 1 does not work." echo " " echo "This machine will be reset to the state it was in when" echo " you received it." echo " Are you sure you want to do this?" echo " 1. Yes" echo " 2. No" echo "Enter your choice: " read warningchoice case $warningchoice in 1) restore_from_permanent ;; *) echo "Returning to main menu"; sleep 2 esac } # this is a function to restore the MBR # from a backup file on the CD restore_mbr() { clear echo " " echo "Restoring Master Boot Record (MBR)" dd if=/KNOPPIX/backup/MBRbackup.bin of=/dev/hda bs=1 count=512 echo " " echo "Master Boot Record restored." reboot_to_hd } restore_from_permanent() { clear echo "Will shortly begin restoring from permanent backup file " echo "located on this disk." echo " " echo "This will take a while, please be patient." echo " " echo "-==DO NOT TURN OFF COMPUTER DURING THIS TIME==-" sleep 3 echo "Format hda1" mkfs.ext2 /dev/hda1 clear echo "Format hda3" mkfs.ext2 /dev/hda3 clear echo "Partitions formatted." mount_drives clear echo "Beginning hda1 restore" cd /KNOPPIX/backup tar -xvzf hda1backup.tar.gz -C / clear echo "hda1 restore complete." sleep 5 echo "Beginning hda3 restore" tar -xvzf hda3backup.tar.gz -C / clear echo "hda3 restore complete." sleep 5 clear echo "Copying hda1backup.tar.gz to hda3" cp /KNOPPIX/backup/hda1backup.tar.gz /hda3/hda1backup.tar.gz sleep 2 clear echo "Unmounting partitions" sudo umount /dev/hda1 sudo umount /dev/hda3 echo " " echo "Restoration Complete." reboot_to_hd } interrupt_trapper() { echo "Cannot exit script this way." echo "To exit, select Option 5 or Option 6" echo "from the Main Menu" } menu() { trap interrupt_trapper INT clear echo " MAIN MENU " echo " " echo "Choose from one of the options below to begin" echo " " echo "1. Restore Operating System from Harddrive Backup" echo "2. Do a Complete Restore from Backup on this disk" echo "3. Make a new backup of the system." echo "4. Restore MBR" echo "5. REBOOT" echo "6. Exit to Live session" echo " " echo " For more information on the presented options," echo " just press ENTER without any number." echo " " echo "If you're ready to begin, just type the" echo "number of your choice, and then press ENTER" read choice case $choice in 1) restore_from_hda3 ;; 2) warning ;; 3) backup_to_hda3 ;; 4) restore_mbr ;; 5) reboot_to_hd ;; 6) exit ;; *) information esac } } #below is the main flow of the script #everything else is a function. initialize title while :; do menu done |