Skip to content

Instantly share code, notes, and snippets.

@VirtuBox
Last active September 16, 2020 16:48
Show Gist options
  • Save VirtuBox/2713c7c1a5987b8c6415cdff11410e17 to your computer and use it in GitHub Desktop.
Save VirtuBox/2713c7c1a5987b8c6415cdff11410e17 to your computer and use it in GitHub Desktop.
Backup disk on a remote storage with dd & sshfs

Install sshfs & pigz (multithreaded gzip) or zstd

sudo apt-get install sshfs pigz zstd -y

create and mount remote storage with sshfs

sudo mkdir /mnt/remote
sudo sshfs root@REMOTE-SRV-IP:/path/storage /mnt/remote

backup disk

with pigz

dd if=/dev/sda ibs=4096 conv=noerror | pigz -9 > /mnt/remote/backup.image.gz

with zstd

dd if=/dev/sda ibs=4096 conv=noerror | zstd -c > /mnt/remote/backup.image.zst

Restore your disk

by downloading your backup with wget

wget -O- 'http://your-serve-ip/backup.image.gz' | unpigz | dd of=/dev/sda ibs=4096

from the remote storage

zcat /mnt/remote/backup.image.gz | dd of=/dev/sda ibs=4096
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment