Translation(s): Français

This page aims to sum up the way of doing clone of Debian machines.


partclone allows to clone and restore partitions. It cannot clone in live (the partition must be umounted). In order to clone a entire system, you need to use a LiveUSB to clone (systemrescue or clonezilla for instance)

To clone a partition

To clone an ext4 partition in a file :

partclone.ext4 -c -s /dev/sda1 -o ~/pc1.img

To clone an ext4 partition to a SSH server, compression the image with Gzip:

partclone.ext4 -c -s /dev/sda1 |gzip -c |ssh adrien@serveur 'cat > ~/pc1.img.gz'

To restore a partition

To restore from a file:

partclone.ext4 -r -o /dev/sda1

To restore from the SSH server:

ssh adrien@serveur 'zcat ~/pc1.img.gz' |partclone.ext4 -r -o /dev/sda4

== A simple guide to cloning debian onto a bootable usb/ssd and maintaining it as a backup.

-- with gparted make a single partition ext2 fs (ext2 slightly less hard-wearing on ssd) and label backupos.

:/# mount /dev/sdb1 /media/backupos -t ext2

:/# blkid

-- gives details to be used in /etc/fstab on ssd. Typical output is....

-- /dev/sdb1: LABEL="backupos" UUID="767ba9eb-bf18-46c0-928d-b3ff13d18f1c" TYPE="ext2"

-- make a swapfile for use when booted into the ssd directly

:/# dd if=/dev/zero of=/media/backupos/swapfile bs=1M count=1024

-- copy root from / to ssd labelled backupos

:/# rsync -auv --"exclude=/home/user/[a-zA-Z0-9]*" --"exclude=/proc/*" --"exclude=/lost+found/*" --"exclude=/dev/*" --"exclude=/mnt/*" --"exclude=/media/*" --"exclude=/sys/*" --"exclude=/tmp/*" --"exclude=/etc/fstab*" / /media/backupos

-- maybe do that a couple of times - preferably with nothing running - until minimum files are being copied over.

:/# update-grub

-- watch for grub finding both main and clone systems

:/ grub-install --recheck --root-directory=/media/backupos/ /dev/sdb

-- edit /media/backupos/etc/fstab to mount the correct device on / when booting the ssd from the BIOS menu

proc /proc proc defaults 0 0

767ba9eb-bf18-46c0-928d-b3ff13d18f1c / ext2 errors=remount-ro 0 1

-- when booted into the ssd direct, activate swap with

/# swapon /swapfile