Supertext Home
Chief of the System Blog

Very simple MySQL backup via FTP script

November 9th, 2007 by Remy Blaettler

There are tons of pretty enhanced scripts out there to make backup and also to copy them to FTP sites, but what I needed was just something really simple to have my daily backup saved somewhere.

The script below will dump your DB into the backup.sql file and copy it to an FTP server of your choice into the root directory of that user. Can’t be any simpler.

Here it is:

The BackupAndFTP.cmd file:

mysqldump -uuserName -ppassword DBName > backup.sql ftp -s:ftpcommands.txt ftp.hostname.com

The ftpcommands.txt file:

username password binary put backup.sql bye

Just put both code blocks into an individual file, replace the usernames and passwords (first for MySQL and then for the FTP access), replace DBName with the name of the database you wanna save and that’s it.

Related Posts

  1. Changing the MySQL my.ini File in Windows Vista
  2. Breadcrumbs to indicate the Checkout Progress
  3. Using Log4Net for a Windows Console Application
  4. Change a CSS Control Adapter in Code

2 Comments to “Very simple MySQL backup via FTP script”

  • Reto Laemmler says on January 22nd, 2008 at 8:45 am :

    Your solution is nice and simple. It may not work in the future once you have millions of rows in a table. That raw backup.sql file will take a long time to backup and restore.

    That’s how we did in the days of Xcellery: http://xcellery.blogspot.com/2007/05/powershell-and-amazon-s3.html

    It’s was sort of a hotbackup. We copied the real DB files incl. its log files. You need to quickly turn off the DB server before you copy the files. That’s the disadvantage but the backup process goes pretty fast.

    In the future I would probably simply use a mirrored DB server.

    Gotta go back to work now. :-)

  • Remy Blaettler says on January 22nd, 2008 at 9:07 am :

    I guess a mirrored server would be the way to go. Turning off the server is not really an option I think.

Leave a Reply

Supertext

Blog Home

News
Contact
Newsletter
Portrait
Network
Team
Customer
Partner
Press
Examples

Search the blog
Facebook
Twitter