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:
1. Manually create a database backup
Section titled “1. Manually create a database backup”First, we want to create a database backup to ensure we have a restore point in case anything goes wrong.
- Navigate to the
porta-onprem-bundle\porta-helpers\porta-database\actiondirectory.- In Porta version 2.3.115+, this will instead be
porta-onprem-bundle\porta-helpers\porta-database\actions\create-backup.bat.
- In Porta version 2.3.115+, this will instead be
- Double-click on the
create-backup.batscript 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.
- Open Powershell
- Run the following command, and replace:
filename.zip: with the name of the backup you created in step 1D:\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
3. Purge the MySQL binary logs
Section titled “3. Purge the MySQL binary logs”3a. Stop replication on the machine
Section titled “3a. Stop replication on the machine”- Navigate to the
porta-onprem-bundle\porta-helpers\porta-database\actiondirectory.- In Porta version 2.3.115+, this will instead be
porta-onprem-bundle\porta-helpers\porta-database\actions.
- In Porta version 2.3.115+, this will instead be
- Double-click on the
STOP-repl.batscript 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”- Navigate to the
porta-onprem-bundle\porta-helpers\porta-rundirectory.- In Porta version 2.3.115+, this will instead be
porta-onprem-bundle\porta-helpers\porta-run\sysadmin\CLI.
- In Porta version 2.3.115+, this will instead be
- Double-click on the
access-mysql.batscript to run it and access the MySQL shell. - 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;
4. Decrease the binlog expire time
Section titled “4. Decrease the binlog expire time”- Navigate to the
porta-onprem-bundle\porta-helpers\porta-rundirectory.- In Porta version 2.3.115+, this will instead be
porta-onprem-bundle\porta-helpers\porta-run\sysadmin\CLI.
- In Porta version 2.3.115+, this will instead be
- Double-click on the
access-mysql.batscript to run it and access the MySQL shell. - In the MySQL shell, run the command
SET PERSIST binlog_expire_logs_seconds=259200;
5. Start replication on the machine
Section titled “5. Start replication on the machine”- Navigate to the
porta-onprem-bundle\porta-helpers\porta-database\actiondirectory.- In Porta version 2.3.115+, this will instead be
porta-onprem-bundle\porta-helpers\porta-database\actions.
- In Porta version 2.3.115+, this will instead be
- Double-click on the
START-repl.batscript to run it.