Script solution to save and restore entire hard disks

Post there if you plan to contribute to this SystemCd
eomanis
Posts: 9
Joined: 15 Apr 2010, 17:24

Script solution to save and restore entire hard disks

Postby eomanis » 15 Apr 2010, 19:12

Hello guys,

some time ago I did a project thesis for my studies which involved developing a way to create some sort of "system reset DVD" in an automated way. I carried it out using SystemRescueCd and some bash script files for customization.
I got the impression that some of the stuff I had scripted had potential to be developed further towards providing a way to back up and restore entire hard disks more conveniently than manually saving a "parted /dev/sda unit b print" output, the Master Boot Record along with other potential boot code areas and letting partimage have a go at every partition on the disk.
Long story short, here's my project thesis spin-off that I pragmatically call the "Disk Imaging Tool" and that I use to back up my computers' hard disks:

http://eomanis.anydns.com/diskimgtool/diskimgtool_2010-06-09.7z
Instructions how to create a bootable USB drive are provided in the archive file.

For those interested, there is also a rough overview of how an MSDOS-partitioned boot disk may look and how the Disk Imaging Tool saves and restores such a hard disk:
http://eomanis.anydns.com/diskimgtool/diskimgtool_technical_details_2010-05-25.pdf
Please note that I did this documentation to the best of my knowledge, yet I may be wrong with some things. I do not cite any sources for this, it just seems to be that way.

What it can do:
- back up and restore full hard disks that contain an msdos partitioning scheme (partitions with file systems unsupported by partimage will be skipped)
- restore a full disk backup to a target hard disk that is at least the same size as the source hard disk
- build and burn a customized SystemRescueCd .iso image with an included full disk backup that can reset a computer's hard drive to a saved state (so-called Reset DVD)

What it can NOT do:
- handle other partitioning schemes than msdos
- handle LVM volumes
- handle ext4 or any other file system that partimage does not support

This is my first larger set of shell scripts. Expect some redundant code, along with inconsistent looks/coding style. Still, the Disk Imaging Tool may be useful for some people, so I've decided to post it in the SystemRescueCd forum as soon as I got it in a usable state.

Here it is in its testing virtual machine:
Image
Image
Image
Image
Image
Image
Image

Have fun,
--eomanis

@edit updated all hyperlinks because dyn.com discontinued their free services
Last edited by eomanis on 04 May 2014, 21:16, edited 10 times in total.

eomanis
Posts: 9
Joined: 15 Apr 2010, 17:24

Re: Script solution to save and restore entire hard disks

Postby eomanis » 02 May 2010, 14:32

Version 2010-05-03
Bugfixes:
    - copydimgtoolfiles.sh: The file "knownerrors.txt" is now included when generating an .iso file of the Disk Imaging Tool
    - connect.sh: Option "Mount [d]efault smb share: ..." was broken
    - connect.sh: Now mounting SMB shares with option "iocharset=utf8" by default
    - restoredisk.sh: Counting variables for successful/unsuccessful partition restorations fixed
    - restoredisk_batch.sh: Counting variables for successful/unsuccessful partition restorations fixed

Version 2010-05-16
Bugfixes:
    - restore_bootcode.sh, other script files: Changed the backup and restore procedures to include all the data stored in front of the physically first partition (fixes inability to restore GRUB and possibly other boot loaders)
    Watch out: Since the previous versions did not save this data, full disk backups made by those versions cannot be restored anymore!
    - All script files: Replaced self-coded "sed" commands with "dirname" and "basename" where possible
    - comparepartitioning.sh: Ignore extended partitions during comparison (i.e. only compare primary and logical partitions)
    - knownerrors.txt: Added entry ("docache" does not work)
Features:
    - savedisk.sh: Added final prompt

Version 2010-05-17
Bugfixes:
    - validate_srcdir.sh: Fixed backup folder validation for the new backup procedure
    - restoredisk.sh: Use "validate_srcdir.sh" to validate backup folders instead of own code
Misc:
    - Various script files: Code cleanup, improved descriptions

Version 2010-05-18
Bugfixes:
    - savedisk.sh: When the script was cancelled at the final prompt, an empty folder was left behind. Fixed.
    - connect.sh, connect.config: Added "nounix" to the SMB mount options for better compatibility with Samba servers as storage device.

Version 2010-06-09
Bugfixes:
    - sysresccd_to_usb.bat: Batch script failed to appropriately alter the extracted SystemRescueCd files in sysresccd_usb
    - copydimgtoolfiles.sh: Updated the files that are being copied to include all files found on SystemRescueCd version 1.5.5
    - installation.txt: Added description of alternate USB drive installation procedure from Windows using the new SystemRescueCd Windows USB drive installation program
    - Various files: Minor fixes and improvements
Features:
    - getsysrcdmountpnt.sh: Improved directory structure awareness - now e.g. tooltoiso.sh can be run directly from a mounted/extracted .iso image


Return to “Contributions”

Who is online

Users browsing this forum: No registered users and 1 guest