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.
2 Kommentare zu “Very simple MySQL backup via FTP script”
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. 🙂
I guess a mirrored server would be the way to go. Turning off the server is not really an option I think.