Skip to content

Instantly share code, notes, and snippets.

@jsumners
Last active October 11, 2021 15:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsumners/aa63885bffb3270cb1478ee727638d0d to your computer and use it in GitHub Desktop.
Save jsumners/aa63885bffb3270cb1478ee727638d0d to your computer and use it in GitHub Desktop.
Backup disk over ssh
  1. Boot host to be backed up with a rescue image, e.g. SystemRescueCD.
  2. Connect to destination host: ssh -L 8000:localhost:9000 destination.example.com
  3. On destination host: socat -u TCP4-LISTEN:9000,reuseaddr,fork OPEN:/tmp/backup.img.bz2,create,append
  4. On host to be backed up: dd if=/dev/sda | pv | bzip2 -9 | nc localhost 8000

Notes:

  1. socat installed on destination host
  2. /dev/sda is whatever disk is to be imaged and sent to remote host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment