Results 1 to 4 of 4

Thread: MySql FTP server backup script

  1. #1
    Member
    Join Date
    Jan 2007
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default MySql FTP server backup script

    Hello,
    i need script which take dump and zip of all mysql databases from one server machine and put it to another server machine at the end of day for backup.
    Regards

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,514
    Thanks
    17
    Thanked 808 Times in 511 Posts
    Rep Power
    10

    Default

    Is server other end runs ftp server? If so it will be quite easy to do the same.. let me know
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. #3
    Member
    Join Date
    Jan 2007
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Yes ftp server is running

  4. #4
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,514
    Thanks
    17
    Thanked 808 Times in 511 Posts
    Rep Power
    10

    Default

    Here is the simple script, you need to install lftp ftp client. Also setup variables in script :
    Code:
    #!/bin/bash
    ### MySQL Setup ###
    MUSER="root"
    MPASS="PASSWORD"
    MHOST="127.0.0.1"
    MYSQL="$(which mysql)"
    MYSQLDUMP="$(which mysqldump)"
    BAK="/backup/mysql"
    GZIP="$(which gzip)"
    ### FTP Server Info ###
    FTPU="USER" # ftp user
    FTPP="PASSWORD"  # ftp password
    FTPS="10.1.12.1" # ftp server name/ip address
    NOW=$(date +"%d-%m-%Y")
    
    [ ! -d $BAK ] && mkdir -p $BAK || /bin/rm -f $BAK/*
    
    DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
    for db in $DBS
    do
     FILE=$BAK/$db.$NOW-$(date +"%T").gz
     $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
    done
    
    # make sure ftp server has mysql directory to store database
    lftp -u $FTPU,$FTPP -e "mkdir mysql/$NOW;cd mysql/$NOW; mput /backup/mysql/*; quit" $FTPS
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ssh backup particular mysql table / database
    By brothers in forum Databases servers
    Replies: 11
    Last Post: 25th October 2007, 05:06 PM
  2. problem with System + MySQL backup script
    By massoo in forum Shell scripting
    Replies: 1
    Last Post: 20th August 2007, 09:50 PM
  3. MySQL Backup Script
    By krisa in forum Shell scripting
    Replies: 1
    Last Post: 2nd February 2007, 11:57 PM
  4. How do I backup MySQL Databases?
    By chiku in forum All about FreeBSD/OpenBSD/NetBSD
    Replies: 2
    Last Post: 19th August 2006, 07:15 PM
  5. Backup mysql from shell prompt or script
    By raj in forum Linux software
    Replies: 0
    Last Post: 29th July 2006, 11:17 PM

Posting Permissions

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