コンテンツにスキップ

Purging Database Replication Logs

このコンテンツはまだ日本語訳がありません。

The MySQL database’s binary logs can accumulate over time and consume significant disk space. By default, these logs are set to automatically purge every 3 days. However, if you need to manually purge them to free up space, you can follow these steps:

First, we want to create a database backup to ensure we have a restore point in case anything goes wrong.

  1. Navigate to the porta-onprem-bundle\porta-helpers\porta-database\action directory.
    • In Porta version 2.3.115+, this will instead be porta-onprem-bundle\porta-helpers\porta-database\actions\create-backup.bat.
  2. Double-click on the create-backup.bat script to run it.

2. Export the backup to the host machine in case of failure

Section titled “2. Export the backup to the host machine in case of failure”

Copy the file from the porta container to the host machine. This will ensure you have a local copy of the backup outside the WSL environment.

  1. Open Powershell
  2. Run the following command, and replace:
    • filename.zip : with the name of the backup you created in step 1
    • D:\destination\path : with the location you want to save the backup
    Terminal window
    docker cp porta:/var/www/storage/app/Porta-Backups/filename.zip D:\destination\path
  1. Navigate to the porta-onprem-bundle\porta-helpers\porta-database\action directory.
    • In Porta version 2.3.115+, this will instead be porta-onprem-bundle\porta-helpers\porta-database\actions.
  2. Double-click on the STOP-repl.bat script to run it.

3b. Manually purge MySQL binary logs created more than 3 days ago

Section titled “3b. Manually purge MySQL binary logs created more than 3 days ago”
  1. Navigate to the porta-onprem-bundle\porta-helpers\porta-run directory.
    • In Porta version 2.3.115+, this will instead be porta-onprem-bundle\porta-helpers\porta-run\sysadmin\CLI.
  2. Double-click on the access-mysql.bat script to run it and access the MySQL shell.
  3. In the MySQL shell, run the following commands to remove logs older than 3 days.
    • Remember to edit the date in the command to 3 days ago so that it includes any logs more than 3 days old:
    • SET sql_log_bin=OFF;
      PURGE BINARY LOGS BEFORE '2025-12-05 00:00:00';
      SET sql_log_bin=ON;
  1. Navigate to the porta-onprem-bundle\porta-helpers\porta-run directory.
    • In Porta version 2.3.115+, this will instead be porta-onprem-bundle\porta-helpers\porta-run\sysadmin\CLI.
  2. Double-click on the access-mysql.bat script to run it and access the MySQL shell.
  3. In the MySQL shell, run the command SET PERSIST binlog_expire_logs_seconds=259200;
  1. Navigate to the porta-onprem-bundle\porta-helpers\porta-database\action directory.
    • In Porta version 2.3.115+, this will instead be porta-onprem-bundle\porta-helpers\porta-database\actions.
  2. Double-click on the START-repl.bat script to run it.