Skip to content

MySQL Database Backup to FTP Server – Shell Script

MySQL database backup to FTP server - Shell Script for Linux system.

Category
Databases
Covers
FTP, MySQL
Versions & support
About MySQL →

As a system administrator, you need to take backup on daily basis. Backups are very useful to recover data from any crashes or corruption. I have written a simple script to take database backup from MySQL server and upload it to FTP server. Being a system administrator, I recommend keeping a remote copy of your every backup. You can also try our new advance script for MySQL databases backup and upload to remote locations.

Create a shell script file and copy the below script. Then update all the required values and execute.

Setup Details – Edit the above script for the following variable as per your system environment. Place all the values correctly to make the script work properly.

  • LOCAL_BACKUP_DIR => Local direction path to store backup
  • DB_NAME => database name
  • DB_USER => database adminitrator user name
  • DB_PASSWORD => database administrator password
  • FTP_SERVER => ftp server ip for hostname
  • FTP_USERNAME => ftp username
  • FTP_PASSWORD => ftp password
  • FTP_UPLOAD_DIR => ftp server backup path
  • LOG_FILE => log file name and location

I hope this script will help you for taking database backup over the FTP server.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

3 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Back to top