Uncategorized

How to make a byte-for-byte (block-level) backup of a Linux Ubuntu machine remotely

Yes — you can absolutely make a byte-for-byte (block-level) backup of an Ubuntu machine remotely, provided you have either SSH terminal access or remote GUI. Below are the reliable, practical methods people use in real-world sysadmin settings.


✅ 1. Byte-for-byte backup using dd over SSH (most direct method)

This creates a raw disk image exactly the same size as the drive.

On the backup machine (where you want to store the image)

ssh user@remote-machine "sudo dd if=/dev/sdX bs=4M status=progress" | dd of=ubuntu-image.img bs=4M status=progress

Replace /dev/sdX with the correct device on the remote machine (e.g., /dev/sda).

What this does:

  • The remote machine reads its entire disk using dd.
  • The raw stream is piped through SSH.
  • Your local machine writes the image to ubuntu-image.img.

Optional: compress on the fly

ssh user@remote-machine "sudo dd if=/dev/sdX bs=4M | gzip" > ubuntu-image.img.gz

This usually shrinks the image dramatically unless the disk is nearly full.


⚠️ Important notes for dd backups

  • The system can be live, but files may be in use. For a true, consistent snapshot, use LVM or filesystem snapshots (see below).
  • This copies all empty space, so the image = full disk size.
  • Ensure you’re backing up the right device:
    • entire disk: /dev/sda
    • single partition: /dev/sda1

✅ 2. Block-level backup using LVM snapshot + dd (consistent backup on a running system)

If the system uses LVM, this is the safest method.

On the remote machine:

sudo lvcreate --size 2G --snapshot --name rootsnap /dev/vgname/root

Then back up the snapshot:

ssh user@remote-machine "sudo dd if=/dev/vgname/rootsnap bs=4M" | dd of=ubuntu-lvm-snapshot.img

After backup:

sudo lvremove /dev/vgname/rootsnap

This prevents corruption caused by live changes.


✅ 3. Use Clonezilla remotely (SSH-only mode)

Clonezilla can run in:

  • server mode, or
  • client (your machine connects via SSH)

To clone a remote disk to an SSH server:

On the backup server:

sudo systemctl start ssh

Then on the Ubuntu machine, boot Clonezilla (physical console or remote KVM) and choose:

device-image → ssh server

Clonezilla copies disk blocks, only the used ones, so it’s faster than dd.


✅ 4. Use partclone over SSH (more efficient than dd)

partclone copies only used filesystem blocks:

ssh user@remote-machine "sudo partclone.ext4 -c -s /dev/sdX1 -o -" > backup.img

This gives a smaller, faster block-level backup.


✅ 5. Using rsync is NOT byte-for-byte

Useful for normal file backups, but not for disk imaging.
Since you asked specifically for “byte for byte,” rsync does not qualify.


🔥 Recommended approach for most users

If you just want a full raw disk image and downtime isn’t a concern:

Use dd over SSH (method 1) with gzip.

If you want a safe, consistent backup while the system is running:

Use LVM snapshot + dd (method 2).


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.