Skip to content

Instantly share code, notes, and snippets.

@aeurielesn
Created April 5, 2012 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aeurielesn/2314169 to your computer and use it in GitHub Desktop.
Save aeurielesn/2314169 to your computer and use it in GitHub Desktop.
Backup through FTP
#!/bin/bash -e
#
#Define dumpfile name
MYSQLBACKUP= /tmp/dbackup
#Perform MySQL dump
#Replace appropriate USER, PASSWORD and paths to mysqldump, socket, etc.
#Drop in you preferred method - tar versus gzip, etc.
/usr/bin/mysqldump --all-databases -S /tmp/mysql.sock -uUSER -pPASSWORD | gzip -c > $MYSQLBACKUP
#FTP Backup file to remote FTP server
#Replace 192.1681.1.1 with IP address of remote server
#Replace USER & PASSWORD
echo "open 192.168.1.1
user USER PASSWORD
verbose
cd /some/directory/on/remote/server
bin
prompt
mput $MYSQLBACKUP
close
quit" | ftp -n >> /tmp/somelogfile
#Remove the file post transfer. Need to be sure it was ftp'd first
rm -f "MYSQLBACKUP"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment