Backing Up a Database as Root

While it is often easier to manage backups via the UI, you may occasionally need to dump a database manually. We recommend backing up MySQL databases using the customer's environment where possible. You can either:

  • Add an SSH key or a password to the website under developer tools in the website dashboard.
  • Log in to your server as root and use su to switch to the website's unix user.
  • Dump the database as root using the instructions below.

To dump a database as root:

  1. Log in to your system as root. In a multi-server cluster, ensure you are on the specific server running the Database role for that website.
  2. Execute the dump command inside the mysqlcd container:
docker exec mysqlcd sh -c "mysqldump database_name_here > /var/backups/database_name.sql"
  1. The resulting file will be located on the host operating system at:
    /var/local/LxRoot/mysqlcd-backups

We recommend that you rm the backup file once you have moved or utilized it to save disk space.

Warning

Be extremely careful executing commands as root, especially those which directly redirect output to files, as this can overwrite critical system data if paths are entered incorrectly.