Automatic MySQL Backup
In a previous post I wrote about dbsender, a script that would back up your MySQL database, zip the contents and email it to you. It worked very well for me for a long time, but recently hasn't been working at all. I rechecked everything to see what the problem was, but without success.
![]()
My site is hosted on Dreamhost, and the reason I signed up with them was so I could use shell access. No more hours of waiting for conventional FTP installs! I use WinSPC, an open source SFTP client and FTP client for Windows. Its main function is the secure file transfer between a local and a remote computer. Beyond this, WinSCP offers basic file manager functionality. It uses Secure Shell (SSH) and supports, in addition to Secure FTP, also legacy SCP protocol.
When you use ssh to connect to your server, you have what is called "shell access". Here are a few of handy shell commands:
- cd dir [Changes working directory to the directory named "dir"]
- cd .. [Change working directory to the parent directory of the current directory]
- cp sourcefile copiedfile [Copies the file "sourcefile" to the new file "copiedfile"]
- cp * dir [Copies all the files in the current directory to the directory named dir
- ls [List files in the current directory]
- ls -al [List all files (includes hidden files, such as .htaccess) in long format]
- ls dir [List the files in the directory named dir]
- mv sourcefile dir [Moves sourcefile to the directory dir]
- mv sourcefile newfile [Renames sourcefile to newfile]
- pwd [Print Working Directory; it tells you where you are]
- rm filetodelete [Removes the file named filetodelete]
- rm -i filetodelete [Interactive remove; prompts you before deleting the file
- rm *~ [Removes all files in the current directory with a name ending with a ~]
- mkdir newdir[Creates a directory called newdir]
A great tutorial of Dreamhost's Wiki explains in detail how to do an automated MySQL database backup, with the option to zip the file and email it to you. Instructions are also available for a complete domain backup, and I might set that up at a later date, but I can tell you, the MySQL backup works beautifully.
Follow the instructions carefully to set up your script, test it using SSH, then set up a cron job to make the process run automatically.



Leave a comment