There are fixed steps for any backup as :
Select Backup Files
Compress Files to reduce storage
Transfer to backup server.
For having automated backups just setting a cron-job (Linux) or any scheduler (FTP) is required.
Here is the preparation for creating backup script.
Set Backup files / folder which contains multiple files.
BASE_DIR=/root/backup_scripts
LOG=$BASE_DIR/log.txt
BK_FILE_FOLDER=$BASE_DIR/bk_files/
NOW=$(date +"%d-%m-%Y")
Set Back-Up server credentials.
FTPS="192.168.1.1"
FTPU="USER"
FTPP="PASSWORD"
Take Mysql Backup as .sql and compress the SQL file. More details on Mysql Backup here.
mysqldump -pmysqlpassword -u mysqluser --databases database1 database2 databasen | gzip > $BK_FILE_FOLDER/mysql_$NOW.zip
Connect to FTP server and transfer files to FTP Server
ftp -n $FTPS<<EOF
quote USER $FTPU
quote PASS $FTPP
prompt off
mkdir $NOW
cd $NOW
lcd $BK_FILE_FOLDER
mput *
quit
EOF
Log the backup time and/or success/failure to log files. If successful backup delete the files.
if [ "$?" == "0" ]; then
rm -f $BK_FILE_FOLDER/*
else
echo "error in FTP" >> $LOG
fi
Now Set the cron job for executing this batch file after specified intervals.
Find sample file attached. Enjoy :)