Find the answer to your Linux question:
Results 1 to 5 of 5
Hello, I'm new to these forums so I hope I haven't forgotten anything. I've got a Centos 5 machine running with a raid 1 SSD hard drive combo, as I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2010
    Posts
    5

    Pipe mysql dump to FTP without writing to disk


    Hello,

    I'm new to these forums so I hope I haven't forgotten anything.

    I've got a Centos 5 machine running with a raid 1 SSD hard drive combo, as I don't know how or even if it's possible yet to wipe the free disk space clean I need to be careful to not fill all the free disk space.

    As I don't want to fill the free disk space too quickly and was wandering if it is possible to pipe the result of a mysqldump to a FTP client only writing it to the ram and not writing it to this disk.

    I've done a bit of research on the subject and have found the two following commands :

    Code:
    mysqldump < mysqldump options> | gzip > outputfile.sql.gz
    Code:
    tar cf - / | ncftpput -c sonic.sega.co.jp /usr/local/backup.tar
    I would like to combine the two to make something like this :

    Code:
    mysqldump mysqldump_options > | ncftpput ncftpput_options -c SERVER_IP backup.sql
    I haven't actually tried my code as it seems too easy and I'm sure I've got something wrong ! If this command is even correct will it prevent the sql file from being written to the hard drive to my local machine ?

    Thank you.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,390
    This is not possible with ftp, as it lacks streaming support.
    Meaning:
    You can only upload/download files as a whole, but not work within files.

    Protocols allowing this would be cifs or nfs, both shall only be used in *your* network.
    aka in a controlled environment.
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Aug 2010
    Posts
    5
    Thankyou,

    Doesn't
    Code:
    tar cf - / | ncftpput -c sonic.sega.co.jp /usr/local/backup.tar
    involve steaming ? Because I got it from the ncftp docs… from what I understood ncftpput could sort of wait for the whole file to arrive before sending it …

    Is there not a way to put the whole SQL dump to the ram and send it to FTP without writing it to the hard disk ?

  4. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,390
    You might be right, and I am surprised to see that option in the man page.

    Now, if ncftpput would not use a tmp file then it might be exactly what you want.
    Just try it
    mysqldump mysqldump_options | ncftpput ncftpput_options -c SERVER_IP backup.sql

    Note that ">" is left out.
    While this is running, check what it is doing:
    lsof|grep ncftpput
    and look for tmp files
    You must always face the curtain with a bow.

  5. #5
    Just Joined!
    Join Date
    Aug 2010
    Posts
    5
    Thanks I'll give it a go tomorrow !

    I left the > for mysqldump because of the mysql commands being

    Code:
    mysql database > file.sql
    to export and

    Code:
    mysql database < file.sql
    to import, so I presumed that it was necessary to keep the arrow to make sure that it did the right thing.

    I've just comme across this :

    astbss.org/mysqldump-to-a-remote-server

    Seems possible to dump a database via ssh using cat…

    Using the following command :
    Code:
    mysqldump [mysqldump options] | gzip -c | ssh user@remotehost "cat > /path/to/some-file.sql.gz"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •