Very simple MySQL backup via FTP script

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.




Ähnliche Beiträge


2 Kommentare zu “Very simple MySQL backup via FTP script”



  • Reto Laemmler am 22. January 2008 8:45 am Uhr

    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 am 22. January 2008 9:07 am Uhr

    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

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



*