nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

MySql FTP server backup script

This is a discussion on MySql FTP server backup script within the Shell scripting forums, part of the Development/Scripting category; Hello, i need script which take dump and zip of all mysql databases from one server machine and put it ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 09-22-2007, 04:52 AM
Member
User
 
Join Date: Jan 2007
Posts: 47
Rep Power: 0
zafar466
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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-24-2007, 08:57 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Is server other end runs ftp server? If so it will be quite easy to do the same.. let me know
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 09-24-2007, 10:26 PM
Member
User
 
Join Date: Jan 2007
Posts: 47
Rep Power: 0
zafar466
Default

Yes ftp server is running
Reply With Quote
  #4 (permalink)  
Old 09-25-2007, 06:43 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
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
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
ssh backup particular mysql table / database brothers Databases servers 11 10-25-2007 06:06 PM
problem with System + MySQL backup script massoo Shell scripting 1 08-20-2007 10:50 PM
MySQL Backup Script krisa Shell scripting 1 02-03-2007 12:57 AM
How do I backup MySQL Databases? chiku All about FreeBSD/OpenBSD/NetBSD 2 08-19-2006 08:15 PM
Backup mysql from shell prompt or script raj Linux software 0 07-30-2006 12:17 AM


All times are GMT +5.5. The time now is 05:41 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36