Use Clonezilla!
But if you want to do it manually in the shell, with post-quantum encryption, do it this way:
zstd- ZStandard is a real-time compression algorithm with compression ratios similar tobrotlior standard deflate (zip)rust&cargo- cargo is needed to installrage(use package manager of your choice)
Then:
cargo install ragesudo dd if=/dev/sdX bs=4M status=progress iflag=direct conv=sparse | zstd -T0 -5 --progress | rage --encrypt --passphrase > "backup_$(date +'%Y-%m-%d_%H-%M-%S').img.zst.age"Here I'm using symmetric passphrase cypher, but I strongly encourage you to generate a pub/pri keys with rage and use those for assymetric encryption (you can encrypt for decryptyng not just other ppl but yourself as well, when you're specifying recipients).
- Note about ZStandard compression ratio:
The -5 in the zstd arguments is the compression ratio. The sweet spots are:
- Level 3 – 5: Best trade-off between speed and ratio, use for Single-threaded, average CPU or SBCs. 3 gives very good ratio with real-time compression
- Level 7 – 9: Exploits extra cores well, diminishing returns until level 9, Multi-threaded, modern CPU (6+ cores)
rage --decrypt -o - backup_*.img.zst.age | zstd -d --stdout | sudo dd of=/dev/sdX bs=4M status=progress oflag=directtar -cf - /path/to/folder | zstd -T0 -5 --progress | rage --encrypt --passphrase > "backup_$(date +'%Y-%m-%d_%H-%M-%S').tar.zst.age"rage --decrypt -o - your_backup_file.tar.zst.age | zstd -d --stdout --progress | tar -xf -Hope that someone will find this useful.
Author: @tekk