MBR Recovery

If you have a special master boot record, you may want to back it up.
If something wipes it out, it is easy to restore.

Sample only, Edit for your needs, and use only parts applicable to your system / task.

#Mount some disk space on some other pc.  As a last resort, Windows file share via samba
mkdir /media/smb
mount -t smbfs -o username=you,password=pass // /media/smb

mkdir /media/smb/whateverfolder
cd /media/smb/whateverfolder

#Store info about your drive and partitions.
fdisk -l > fdisk-l.txt
cat fdisk-l.txt

#backup the master boot record and partition table 512, boot record only 448
dd if=/dev/sda of=MBR-PT512 bs=512 count=1

dd if=MBR-PT512 of=/dev/sda bs=512 count=1

Other notes for making drive images and backups:

To backup:
#dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c  > sda.img.gz
#dd_rescue -i -l dd-log -v /dev/sda - | gzip -9 -c  > sda.img.gz
dd_rescue -i -l dd-log-backup -v /dev/sda sda.img

To restore your system:
#gzip -x sda.img.gz | dd of=/dev/sda conv=sync,noerror bs=64K
#gzip -x sda.img.gz | dd_rescue -i -l dd-log -v - /dev/sda
dd_rescue -i -l dd-log-restore -v sda.img /dev/sda

#RSYNC Examples
rsync -vaHxe 'ssh -p 22' --progress --compress-level=9 --numeric-ids --log-file=log-2010-10-22 --delete --delete-excluded [email protected]:/source/ /dest-path/

#DeltaCopy rsync for windows via cygwin
rsync.exe -v -rlt -z --chmod=a=rw,Da+x --delete --rsync-path=/usr/bin/rsync --rsh='ssh -p 22' "/cygdrive/C/" "[email protected]:/dest-path/"

No comments: