I would not recommend using FTP for any files you care about (particularly database backups if that database contains customer information), but that is ultimately up to you.
To start with, script the creation of your backups on the Linux server with something like the following:
#!/bin/bash
#
# Call script with:
# /cron-mysql_bkup.sh mysql_hostname mysql_username mysql_password /backup/directory
#
if [ -n "$1" ]; then
MYSQL_HOST="$1"
else
echo "MYSQL_HOST not specified."
exit 1
fi
if [ -n "$2" ]; then
MYSQL_USER="$2"
else
echo "MYSQL_USER not specified."
exit 1
fi
if [ -n "$3" ]; then
MYSQL_PASS="$3"
else
echo "MYSQL_PASS not specified."
exit 1
fi
if [ -n "$4" ]; then
DIR_BKUP="$4"
mkdir -p ${DIR_BKUP}
else
echo "DIR_BKUP not specified."
exit 1
fi
#
# Generate filename
#
BACKUP_FILENAME=`date "+%Y-%m-%d"`".sql"
#
# Dump all databases
#
mysqldump -h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS} --all-databases > ${DIR_BKUP}/${MYSQL_HOST}/${BACKUP_FILENAME}
#
# Write status of the operation to the mysql.log file in the backup directory
#
if [ $? -ne 0 ]; then
echo `date`" - ERROR creating backups of host "${MYSQL_HOST} >> ${DIR_BKUP}/mysql.log
else
echo `date`" - MySQL Backup complete for "${MYSQL_HOST} >> ${DIR_BKUP}/mysql.log
BACKUP_TAR_NAME=${BACKUP_FILENAME}".tar.gz"
tar czf ${DIR_BKUP}/${MYSQL_HOST}/${BACKUP_TAR_NAME} ${DIR_BKUP}/${MYSQL_HOST}/${BACKUP_FILENAME} && rm ${DIR_BKUP}/${MYSQL_HOST}/${BACKUP_FILENAME}
fi
This script will:
- Check to see whether all the
required parameters were set
- Dump all MySQL databases to a file named
YYYY-mm-dd.sql under the backup
directory specified (this directory
will be created if it does not
exist)
- GZIP the file and, if the GZIP
operation succeeds, delete the
original SQL file
This script should be fairly straightforward for you to customize if you wish to - see the Advanced Bash Scripting Guide to learn more about doing so.
... once your databases are backed up and can be found in a specific location, why not automate backup retrieval with WinSCP instead of transferring your files over FTP?