Backup of a partition

Making ready my backup device

On 23.03.2015 I did a backup of partition /dev/sda1.

The new WD disk was formatted with a windows file system that didn't supported big enough file so I formatted it in ext3

mkfs -t ext3 /dev/sdb1      # Build the file system on WD - 1 TB 

Backup

Before performing the backup save the partition metadata

sfdisk -d /dev/sda > ./sda.sfdisk    # backup  partitions metadata 

This is a copy of ./sda.sfdisk

 
# partition table of /dev/sda 
unit: sectors 

/dev/sda1 : start=       63, size=300431502, Id=83, bootable 
/dev/sda2 : start=300431565, size= 12145140, Id= 5 
/dev/sda3 : start=        0, size=        0, Id= 0 
/dev/sda4 : start=        0, size=        0, Id= 0 
/dev/sda5 : start=300431628, size= 12145077, Id=82

To backup the partition I restarted the system using a live-CD and then did a copy of the partition to a normal file

# change directory where your put the partition copy 
cp /dev/sda1 ./sda1-25.03.2015   # on other *nix use dd instead of cp 

You can mount this partition image in loop mode

mount -o loop /media/disk/sda1-25.03.2015 /mnt 

and browse /mnt like a normal file system.

Restore

Then, if you need restore you partition give these commands

sfdisk /dev/sda < ./sda.sfdisk    # restore partitions metadata 
# change directory where your put the partition copy 
cp ./sda1-25.03.2015 /dev/sda1  # on other *nix use dd instead of cp 

Copy on fly a whole disk

ddrescue -n /dev/sda /dev/sdb ddrescue-sda-sdb.log
linux/backup_di_una_partizione.txt · Ultima modifica: 2015/06/08 20:15 da 127.0.0.1
Torna su
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0