Skip to main content

Home

Backing up the MySQL database

This backup procedure is recommended only when the database size is less than 500 GB. The time taken for backup depends upon factors like the hardware of the existing MySQL server, network bandwidth if the backup is going to be in a NAS partition, etc.

For database sizes greater than 500 GB, running MySQL in master/worker is recommended. Contact Unravel Support for help with this configuration.

You can check the size of the database using the following commands:

sudo grep "^datadir=" /etc/my.cnf | awk -F"[=]" '{print $2}' | sudo xargs du -sh
sudo grep "^datadir=" /etc/my.cnf | awk -F"[=]" '{print $2}' | sudo xargs df -h 
  1. Stop all Unravel daemons on the Unravel server before starting the backup procedure. The daemons must remain off until the back up is complete.

    service unravel_all.sh stop
  2. Download the backup script. The MD5 checksum is: c46ef2f46bd2b7ea0a85d79cfa2626ea.

    cd /tmp/
    wget https://preview.unraveldata.com/unravel/tools/db/backup-db.sh
    chmod 755 backup-db.sh
    
  3. Run the backup script with the required parameters as shown, where:

    • backup-dir: The directory to save the backup file to.

    • host: If you aren't restoring the database on the Unravel server this must be the fully qualified domain name or IP address of the MySQL database host.

    • port: Port number for MySQL host,

    • db_name: Name of the database you are backing up.

    • root-password: Root password of the database you are backing up.

    Tip

    If MySQL is running as part of the Unravel server, you can use the following command to get the root password.

    grep 'DB_ROOT_PASSWORD' /srv/unravel/unravel.install.include
    
    /tmp/backup-db.sh -b backup-dir -h host -p port -n db_name -r root-password

    For example

    /tmp/backup-db.sh -b "/tmp/" -h localhost -p 3306 -n unravel_mysql_prod -r unraveldata

    The script outputs the fully qualified file created. You use this file to restore the DB to that point in time. The file name format is /backup-dir/db-name.backup.YYYYtHHMMZ.sql.gz, for example, /tmp/unravel_mysql_prod.backup.20200306t0520Z.sql.gz

  4. Start all Unravel daemons on the Unravel server.

    service unravel_all.sh start