It’s been a long week, and the last thing we want is all our good efforts to get washed out with the next electrical storm … or wacked with a hack atack.
Time to backup your work. Here are 2 things I do to
a) copy my database and
b) get all my goodies into one, downloadable file …
Now some of you are asking, hey, why bother, my webhost provides this stuff via my control panel ? Besides, he backups everything every night. Yeah, well guess what, even when that’s true, it’s not always a reliable backup. Trust me on this one … I’ve been there more times than I care to mention.
I’m going to assume you can and already know how to either telnet or ssh into your host. I’m also going to assume that most of you are Apache bound like I am. If you don’t or can’t, then stop reading right here until you can.
Okay, are they gone? Now log in to your command prompt. In the root of your site, enter:
mysqldump -uMYUSERNAME -pMYPASSWORD --opt myDatabaseNAME > dumpfile.sql
Not sure you’re in the root directory? No problem! I’ve got two commands that will help you get it done. The first gets you there, the second one tells you where you are:
Okay, that creates a file containing ALL of my data for that database. I’ll write an article in a few days how to script together a solution to walk through all your databases.
Now you’re ready to backup and compress your entire site into one, huge, easy-to-download and restore file using the “tar” command. And remember, you’re still in the root directory of your site:
tar -zcvf mybackup.tar.gz *
At this point, FTP your two files to another system (e.g. your PC) … and you’re done for the night … I know I am.