No description
Find a file
Ben Cartwright-Cox 6a019efe28 Harden the init disk imaging functions to deal with weird disks
Either the disks may not be aligned to the MB, or that the drive
has more to read than is reported, either way the old function
would produce files that would be un-restorable since the header would
have already been emitted incorrecly, since hot-clone is pipeable
this is unfixable.

Instead we ensure we only read what we said we would, and then
we try and read more to see if the deive is broken and/or mis
reporting itself.
2021-09-20 17:17:27 +01:00
sys add BLK_io_trace def 2021-09-12 13:43:47 +01:00
utils Tool works, reassemble works, need to abort / handle drops 2021-09-17 02:04:01 +01:00
.gitignore Tool works, reassemble works, need to abort / handle drops 2021-09-17 02:04:01 +01:00
blktrace_linux.go Add file banner, various UX improvements, code-cleanup ish 2021-09-19 22:41:02 +01:00
blktrace_other.go reshuffles -- now tracking "dirty" sectors 2021-09-12 17:22:04 +01:00
dirty-bitmasks.go Tool works, reassemble works, need to abort / handle drops 2021-09-17 02:04:01 +01:00
dirty-bitmasks_test.go Tool works, reassemble works, need to abort / handle drops 2021-09-17 02:04:01 +01:00
go.mod Basic blktrace-ing working 2021-09-12 13:13:19 +01:00
go.sum Basic blktrace-ing working 2021-09-12 13:13:19 +01:00
LICENSE Add Licence 2021-09-20 14:01:23 +01:00
main.go Harden the init disk imaging functions to deal with weird disks 2021-09-20 17:17:27 +01:00
README.md README 2021-09-19 22:51:55 +01:00
reassemble.go Add file banner, various UX improvements, code-cleanup ish 2021-09-19 22:41:02 +01:00

hot-clone

This tool allows you to image a actively changing block device. Including the one the rootfs is stored on.

Backup a device

hot-clone uses blktrace, and needs root to enable it. Performance impact seems to be low, though if you are planning to image a highly loaded disk you will want to change the values of:

  -blktrace.bufcount int
        The amount of buffers for blktrace to keep spare (default 16)
  -blktrace.bufsize int
        The size of each buffer for blktrace (default 65536)

To something higher, Ideally not too high since it will add latency to disk change events.

$ sudo ./hot-clone -device /dev/sdb > sdb.hc
[sudo] password for ben: 
2021/09/19 22:36:27 Read 18.0 MiB -- 0 Dirty sectors (0 event drops)
...
2021/09/19 22:39:48 Read 3.7 GiB -- 360 Dirty sectors (0 event drops)
2021/09/19 22:39:49 Catching up 36/360 sectors
2021/09/19 22:39:49 Catching up 72/360 sectors
2021/09/19 22:39:49 Catching up 108/360 sectors
2021/09/19 22:39:49 Catching up 144/360 sectors
2021/09/19 22:39:49 Catching up 180/360 sectors
2021/09/19 22:39:49 Catching up 216/360 sectors
2021/09/19 22:39:49 Catching up 252/360 sectors
2021/09/19 22:39:49 Catching up 288/360 sectors
2021/09/19 22:39:49 Catching up 324/360 sectors
2021/09/19 22:39:49 Catching up 360/360 sectors
2021/09/19 22:39:49 Done

The output it pipeed to stdout, this is so you can output to a file or a pipe (or directly invoke it from ssh)

Restore a device

You cannot directly restore the output of hot-clone, you will first need to reassemble it. To do this you select -reassemble for the hot-clone output, and -reassemble-output to the device or file you wish to restore to.

$ ./hot-clone -reassemble sdb.hc -reassemble-output sdb.img
2021/09/19 22:40:14 Restoring section (Sector: 0 (len 3959422976 bytes)
$ 

Notice

You should avoid using this tool if you can help it. LVM, MD Raid, and DRBD give you far better (and tested) methods to enable system snapshotting/real time backups.