dd over sftp

Discussion in 'Programming/Scripts' started by quentin, Jul 8, 2008.

  1. quentin

    quentin New Member

    Hi,

    Wondering if someone can help me out with this one:

    I want to make disk images of a server and store them somewhere remote.

    Ofcourse you can do this with dd and upload the file with sftp to a remote server. The downside is that it requires a huge amount of free space to store the temporary disk image file.

    Is there a way to "stream" it directly to a sftp-server?

    As far as I came up with was this:

    dd if=/dev/sda | bzip2 > /backup/disk.img | sftp -b /backup/dd.txt
    -oIdentityFile=/backup/sshkey.key [email protected]

    contents of dd.txt:
    -cd remotebackup
    put /backup/disk.img
    quit

    In this case it will store the disk.img locally first and then send it. So I was wondering if there was an easier way to this and stream it directly.
    (Note: The remote SFTP-server is a Windows-machine, so no linux shell commands can be executed)

    Thanks in forward for any help.


    Best regards,

    Quentin
     
  2. topdog

    topdog Active Member

    You could do that with a combination of dd and nc
     
  3. topdog

    topdog Active Member

    PS: My bad you possible need to run over an encrypted tunnel which nc will not support.
     
  4. topdog

    topdog Active Member

    Am not sure if sftp can accept stdin but it is worth trying
    Code:
    dd if=/dev/sda | bzip2 > /backup/disk.img | sftp user@host:file -
     
  5. quentin

    quentin New Member

    Won't work

    Thanks for your reply, but with the last command you wrote it still will write to a local disk, which results in a huge "temp" file...

    Still couldn't find a solution, but thanks for thinking along with me in this case.

    Best regards,

    Quentin
     
  6. burschik

    burschik New Member

    The OpenSSH scp/sftp commands refuse to transfer non-regular files, so you can not use a named pipe. However, there are other scp/sftp implementations. Maybe one of them will do what you want.
     
  7. quentin

    quentin New Member

    Ok

    Ok thanks for your replies.

    In short: It just can't be done this way...

    Does anyone know another program which can do the trick? I just want to image the disk on the fly to a remote server.

    If any other backupsoftware can do something similar, it's ok too.


    Best regards,

    Quentin
     
  8. falko

    falko Super Moderator ISPConfig Developer

    You might want to take a look at SystemImager. It uses rsync to store the images on a remote server.
     
  9. lintoolman

    lintoolman New Member


    Cryptcat could be used in leu of nc for an encryted tunnel.
     

Share This Page