Backing Up Drupal
Making backup copies of your Drupal site is essential, especially when you are doing site development. There are two components of Drupal that must be backed up: the database and your unique site files in the
sites folder.
Backing Up Your Drupal Database
- Log in to phpMyAdmin by going to http://localhost/phpmyadmin/
- Choose the Export link at the bottom of the main screen
- In the Export panel at left, choose your Drupal database and make sure that SQL is selected below
- In the Option panel at right, make sure the following are selected:
- Database export options
- Structure
- Add IF NOT EXISTS
- Add AUTO_INCREMENT value
- Enclose table and field names with backquotes
- Data
- Complete inserts
- Extended inserts
- Use hexadecimal for BLOB
- Export type (set to INSERT)
At the bottom, be sure to select Save as file. Rather than File name template, I put in something like
drupal-backup-yyyy-dd-mm-hh (e.g.,
drupal-backup-2009-01-22-14) and then deselect "remember template. For compresssion, choose "gzipped."
Once you've double-checked your settings, hit the Go button at lower right. A download will begin of your database file.
Backing Up the Site Folder
You can, of course, back up your entire
htdocs folder. But if you make multiple, frequent backups, this can be cumbersome. Instead, you can simply back up the
sites folder, which includes both the
default folder (with your settings file,
settings.php) and the
all folder with your themes and modules.
Word to the Wise
With both your SQL and folder back ups, be sure to store these on multiple computers, or even zip them up and email them to yourself.
Rebuilding a Drupal Site from Your File & Database Backups
Copy your site's files into the
/xampp/htdocs/ folder. Easy enough.
While you can use PHPMyAdmin to export databases, it often times out on
importing databases. So rather than use PHPMyAdmin, it's better to rebuild the database from the command line. Mac users will follow similar steps, except you'll need to find the Terminal application and run it (rather than the DOS prompt below).
First, copy your
.sql file into the
xampp/mysql/bin folder; you might rename it to something simple, like
hpkcc.sql; you can delete this file once you've completed the steps below.
Now the real fun starts:
- Start XAMPP (if you don't have it running already)
- Go to Windows' Start menu and click Run...
- In the box that comes up, type cmd and hit Return
- A new DOS window comes up; type the letter of your USB drive followed by a colon (e.g., G:) and hit Return
- Then, type cd xampp\mysql\bin (which changes directories to your bin folder where mysql lives and where you copied your .sql file) and hit Return
- Now start mysql by typing mysql.exe --user=root --password=unsafe (assuming you set your root mysql password to unsafe) and hit Return
- Finally, import the database by typing SOURCE hpkcc.sql (or whatever the name is of your .sql file) and hit Return
- You'll then see the queries run past; when the database is done importing, you'll just see the mysql> prompt; type exit, hit Return and then type exit again and hit Return again.
Done!
There is one comment on this page. [Display comment]