Backing up the database of a Drupal site

Drupal files are the skeleton; the database is everything else. Pages, users, menus, permissions, site configuration and the list of enabled modules all live in there. Without it there is no site, however many files you kept.

The other half is in backing up the files of a Drupal site. Always take both at the same time.

Finding out which database it is

An account can hold several databases and the names tell you nothing. Your Drupal database is written in sites/default/settings.php, inside the installation, in the connection section. Open it in cPanel File Manager and note the database name, the user and the table prefix. If you have never worked with databases in cPanel, start at creating databases and using phpMyAdmin.

That settings.php holds the database password in plain text. Do not e-mail it, do not paste it into a support ticket, and do not leave a copy of it inside a public directory.

Exporting with phpMyAdmin

1 In cPanel, open phpMyAdmin and pick the Drupal database in the left column.
2 Click the Export tab.
3 Choose the quick method and the SQL format, which is what Drupal takes back without any work.
4 If the database is large, switch to the custom method and set compression to gzip. The file gets far smaller and the browser has a better chance of delivering all of it.
5 Click Go and store the file off the server.
Put the date in the filename. A folder holding backup.sql, backup2.sql and backup-final.sql is useless on the day you need it. Database name plus date solves it.

When phpMyAdmin is not enough

Exporting through phpMyAdmin runs inside your browser and is bound by the PHP limits: execution time and memory. On a Drupal with years of content and log entries, the page can simply stop and hand you a file cut off mid sentence, with no visible error. On those limits, see PHP limits.

Symptom What to do
The file downloads but is far smaller than expected It was truncated. Open it in a text editor and see whether it stops mid statement. Use JetBackup instead of phpMyAdmin.
The page goes blank or returns a 500 You hit the time or the memory limit. Export table by table, or use JetBackup.
You want database and files from the same instant Use the Softaculous backup in the installations list, which takes both halves in one go.
You want the database as it was on a specific past day Only JetBackup gives you that. See restoring with JetBackup.

Putting a copy back

1 Export the current database first, even if it looks broken. If the restore goes worse than the problem, that is your way back.
2 In phpMyAdmin, open the database, go to Operations and drop every table, or create a fresh empty database.
3 Use the Import tab and send the SQL file.
4 If the file is too large to upload through the browser, put it on the account with File Manager and import it from there, or ask us.
5 Check that the files come from the same moment as the database. A new database on old files, or the reverse, gives you a Drupal that boots and then falls over.
Import overwrites, and there is no undo. If you are unsure which copy is the good one, restore it onto a test subdomain first and check it there. See a test site.

Does the export stop halfway, or arrive truncated? Send us the database name and we will take care of it.

Open a support ticket

SEE ALSO

Hosting plans and what each one includes

Support Policy

Frequently asked questions

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from $5.36/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?