I am using MySQL as the database system for my application on a Linux system. Every week I update the system and take backups (mysqldump) of the databases changed (2 databases). I then .tar.gz them and ftp the resulting file to a remote Windows server, after which I remove the original backups and tar.gz files from the Linux server. Being a complete novice when it comes to Unix systems, I would like to know if it is possible to write a script which would do all this automatically, i.e. perform the following steps.
1) Backup database A to A.sql (mysqldump) 2) Backup database B to B.sql (mysqldump) 3) tar -cvzf dest.tar.gz A.sql B.sql 4) ftp dest.tar.gz to ftp@remoteserver.com 5) Delete A.sql, B.sql, dest.tar from local server
It would be great if I could get some steps in the right direction! Thanks in advance, Tim
Best Answer
I would not recommend using FTP for any files you care about (particularly database backups if that database contains customer information), but that is ultimately up to you.
To start with, script the creation of your backups on the Linux server with something like the following:
This script will:
This script should be fairly straightforward for you to customize if you wish to - see the Advanced Bash Scripting Guide to learn more about doing so.
... once your databases are backed up and can be found in a specific location, why not automate backup retrieval with WinSCP instead of transferring your files over FTP?