# Backing Up a Database as Root

We recommend backing up MySQL databases using the customer's environment. You can either:

  1. Add an SSH key or a password to the website under "developer tools" in the website dashboard
  2. Log in to your server as root and "su" to the website's unix user
  3. Dump a database as root

To dump a database as root:

  1. Log in to your system as root. If you have a multi server cluster, this should be the server running the database role for the website you wish to back up.
  2. docker exec mysqlcd sh -c "mysqldump database_name_here > /var/backups/database_name.sql"
  3. You will find the resulting file in /var/local/enhance/mysqlcd-backups on the host o/s.

We recommend that you rm the backup file when you're done.

WARNING

Be careful executing commands as root, especially those which directly redirect output to files.