Backing Up a Database as Root

It is recommended to back up MySQL databases using the customer's environment. You can do this by either:

  • Adding an SSH key or password in the "Developer Tools" section of the website dashboard.
  • Logging into the server as root and switching to the website's Unix user.

Steps to Dump a Database as Root:

  1. Log in to your system as root. If you're using a multi-server cluster, this should be the server running the database role for the website you wish to back up.
  2. Run the following command to dump the database:
    docker exec mysqlcd sh -c "mysqldump database_name_here > /var/backups/database_name.sql"
    
  3. The backup file will be saved in /var/local/enhance/mysqlcd-backups on the host operating system.

It is recommended to remove the backup file once you're done:

rm /var/local/enhance/mysqlcd-backups/database_name.sql

WARNING:

Be cautious when executing commands as root, especially those that redirect output to files.

Was this answer helpful? 0 Users Found This Useful (0 Votes)