Last active
February 22, 2024 03:03
-
-
Save saltlakeryan/4aa49f19a40b83a1a7d2 to your computer and use it in GitHub Desktop.
Redo Backup Notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The following are command line commands for backing up /dev/sda1 in the same manner | |
that "redo backup and restore" uses. Note that the MD5 of the partition files will | |
not be the same because gzip stores info about the current time | |
(http://superuser.com/questions/617934/): | |
#mount network drive | |
mount.cifs '//host.example.com/fab/temp' /mnt/backup -o username=myuser,password=mypass | |
#save backup list (sda1 in our case) | |
echo sda1 > /mnt/backup/20141009.backup | |
#save MBR | |
dd if=/dev/sda of=/mnt/backup/20141009.mbr bs=32768 count=1 | |
#save sfdisk info | |
sfdisk -dx /dev/sda > /mnt/backup/20141009.sfdisk | |
#save size of partition | |
BYTES=$(fdisk -l /dev/sda | grep '/dev/sda:' | perl -pe 's/.*, (\d+)\D.*/$1/') | |
echo $BYTES > /mnt/backup/20141009.size | |
#save partition | |
partclone.ntfs -c -F -L /partclone.log -s /dev/sda1 | gzip -c --fast | split -d -a 3 -b 2048m - //mnt/backup/20141009_part1. | |
Here are the commands for doing a restore: | |
#restore MBR | |
dd of=/dev/sda if=/mnt/backup/20141009.mbr bs=32768 count=1; sync; | |
#restore partition table | |
sfdisk -fx /dev/sda < /mnt/backup/20141009.sfdisk; sync | |
#check partition table (redo verifies that output is "1") | |
file /dev/sda1 | grep 'block special' | wc -l | |
#get number of blocks for sda1 | |
cat /sys/block/sda/sda1/size | |
#get number of bytes for sda1 (redo probably ensures this matches .size file) | |
echo $[ $(cat /sys/block/sda/sda1/size) * 512 ] | |
#zero out beginning of sda1 (why?) | |
umount /mnt/sda1 2>&1; dd if=/dev/zero of=/dev/sda1 bs=1K count=1000; sync | |
umount /dev/sda1 2>&1 | |
#do the restore | |
cat //mnt/backup/20141009_part1.* | gzip -d -c | partclone.restore -F -L /partclone.log -O /dev/sda1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment