Wiki : hacking:mirroring_machines_using_ssh
 

Mirroring machines using SSH

When you have a machine working that took you a lot of time to build it up and you need to clone it, there is onw simple way to do it with a single Unix command.

First, install the same Unix on the new machine, set up the network properly and run, on the original machine, the following commands:

$ tar cfpsP - /usr /etc /lib /var (...) | ssh dest -C tar xvf -

Explained:

  • TAR
    1. cf: in mode create-file …
    2. psP: preserve owner, order and don't strip leading /
    3. -: to stdout …
    4. /usr …: getting everything (you may get /usr or /var or whatever you want here)
  • SSH
    1. piping to ssh
    2. -C: compressing the channel (very important!)
    3. running tar on dest machine
  • TAR again
    1. xf: in mode extract-file …
    2. v: verbose, to see the files being created (can be omitted)
    3. -: from stdin

In a nutshell, you're creating a tarball of your whole system, piping it through an encrypted and compressed channel to the dest machine where another tar is running to extract the files in the right place.

Beware that, because of the -P, it'll override everything the dest machine have in the same location.



 
hacking/mirroring_machines_using_ssh.txt · Last modified: 05 09 2007 19:15 (external edit)
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki