Simple scheduled MySQL database backups with FTP offsite hosting

A simple, scheduled MySQL database backup method with zipped files, archive pruning and FTP/offsite upload

After a fruitless search for free MySQL backup tools, the solution turned out to be surprising – using good old-fashioned batch scripting to surprising affect! This leverages the MySQLDump tool which produces .sql files as backups.

This simple script will backup selected databases and do the following:

  • keep rolling versions (backups older than your specified number of days will be deleted.
  • zip them to save on storage
  • upload them to an FTP site
  • keep an ongoing log of operations

Process

  1. Save the batch file below somewhere on your server and ammend the “USER VARIABLES HERE” section
  2. Create a shortcut pointing to this. Go into properties and set to “Run as Administrator.” You need this to leverage the FTP functions.
  3. Run the two commands below through an elevated command prompt to allow the ftp function to work:
  4. Set up a task-schedule to run the backup by pointing to the shortcut (not the batch file)

Script:

 

About stigzler 47 Articles
Chief crook and wattle bosher.

Be the first to comment

Leave a Reply

Your email address will not be published.


*