What is the fastet way to backup/restore a bootable USB stick?

Hi,

before experimenting with the NomadBSD USB stick I decided to test a backup and restore. I used dd to create a gz archive, then I deleted the partitions and restored the USB stick from the backup. Does a faster approach, then using dd exist? My guess is that dd is the only way, just doing it without compression could speedup doing a backup or restore. Am I mistaken?

Backup:

[root@archlinux rocketmouse]# time dd if=/dev/sdf | pv | gzip -c >/mnt/u4.fantec/2020-Apr/nomad+ext4_usb_stick.img.gz; echo $? 
60493824+0 records inMiB/s] [                                                                                                        <=>                                                      ]
60493824+0 records out
28.8GiB 0:06:08 [80.2MiB/s] [                                                                                                     <=>                                                         ]
30972837888 bytes (31 GB, 29 GiB) copied, 368.269 s, 84.1 MB/s

real	6m8.278s
user	6m22.988s
sys	1m39.291s
0

Before deleting the partitions:

[root@archlinux rocketmouse]# fdisk -l /dev/sdf 
Disk /dev/sdf: 28.87 GiB, 30972837888 bytes, 60493824 sectors
Disk model: TransMemory     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x90909090

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdf1             64    81983    81920   40M ef EFI (FAT-12/16/32)
/dev/sdf2  *       81984  8286271  8204288  3.9G a5 FreeBSD
/dev/sdf3       30320640 60493823 30173184 14.4G 83 Linux
/dev/sdf4        8286272 30320639 22034368 10.5G a5 FreeBSD

Partition table entries are not in disk order.

After deleting the partitions:

[root@archlinux rocketmouse]# fdisk -l /dev/sdf 
Disk /dev/sdf: 28.87 GiB, 30972837888 bytes, 60493824 sectors
Disk model: TransMemory     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x90909090

Restore:

[root@archlinux rocketmouse]# time gunzip -c /mnt/u4.fantec/2020-Apr/nomad+ext4_usb_stick.img.gz | pv | dd of=/dev/sdf; echo $? 
28.8GiB 0:53:33 [9.19MiB/s] [                                            <=>                                                                                                                  ]
60493824+0 records in
60493824+0 records out
30972837888 bytes (31 GB, 29 GiB) copied, 3236.56 s, 9.6 MB/s

real	53m56.565s
user	4m50.819s
sys	4m9.994s
0

I didn’t boot the restored nomadBSD yet, but all looks good:

[root@archlinux rocketmouse]# fdisk -l /dev/sdf 
Disk /dev/sdf: 28.87 GiB, 30972837888 bytes, 60493824 sectors
Disk model: TransMemory     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x90909090

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdf1             64    81983    81920   40M ef EFI (FAT-12/16/32)
/dev/sdf2  *       81984  8286271  8204288  3.9G a5 FreeBSD
/dev/sdf3       30320640 60493823 30173184 14.4G 83 Linux
/dev/sdf4        8286272 30320639 22034368 10.5G a5 FreeBSD

Partition table entries are not in disk order.

Regards,
Ralf

You can try Clonezilla . I use it to backup an entire disk to a Samba share, but it works to backup to a local disk too.