Porta VM Disaster Backup and Restore
This page covers:
- how Porta VM creates and stores database backups,
- how to take one manually,
- how to restore from one,
- and how to recover from data loss affecting one or several machines in a replication group.
For diagnosing why a failure happened in the first place, see the Porta VM Troubleshooting guide.
How automatic backups work
Section titled “How automatic backups work”Every three hours, Porta creates a backup of the database on a non-primary machine (usually the arbiter) and stores it inside the porta container at:
/var/www/storage/app/Porta-BackupsEach backup is a ZIP archive containing an SQL dump of the database. The archive name has the format:
machine_type-machine-connection_name-backup-Y-m-d-H-i-s.zipFor example, a backup created on the arbiter at 14:30 on 2026-05-20 would be named arbiter-machine-mysql-3-backup-2026-05-20-14-30-00.zip.
Alternate setups
Section titled “Alternate setups”The location and frequency change depending on the topology:
- Single-machine setup: backups are created on the single machine.
- Single machine with an isolated backup machine: backups are created on both machines independently.
- Three-machine replication group: backups run on the arbiter by default. Verify by looking for the most recent backup ZIP inside each machine’s
portacontainer.
Container and port reference
Section titled “Container and port reference”| Machine role | Database container | MySQL port | Replication port |
|---|---|---|---|
| Main | porta-db | 3306 | 33061 |
| Backup | porta-db-2 | 3307 | 33062 |
| Arbiter | porta-db-3 | 3308 | 33063 |
Checking replication health before recovery
Section titled “Checking replication health before recovery”Before any destructive recovery step, capture the current state of the replication group so you can confirm afterwards that the recovery worked:
porta_all_group_statusshows the replication group as reported by every machine. Requires correct/etc/hostsentries on the machine running it.porta_group_statusshows the replication group as reported by this machine only.porta_main_db_logs,porta_backup_db_logs, andporta_arbiter_db_logsshow the MySQL error log on each role. Use the_followvariants to tail live output.
Manually creating a backup
Section titled “Manually creating a backup”Take a manual backup any time, especially before a destructive operation like a database reset.
Inside the VM, run:
porta_backup_dbThe resulting backup is saved inside the porta container at /var/www/storage/app/Porta-Backups, with the same naming format as automatic backups.
Restoring from a backup
Section titled “Restoring from a backup”Inside the VM, run:
porta_restore_dbThe helper prompts with a list of available backup files in the local backups directory. Enter the number corresponding to the backup you want to restore and press Enter.
Single-node disaster recovery
Section titled “Single-node disaster recovery”Use this procedure when one machine in a replication group has lost data, but the other machines in the group are healthy and have an authoritative copy of the data.
There is no need to use a backup file in this case — the broken database can simply be reset, after which it will join the existing group as a new member and replication will fill it in from the surviving machines.
-
Confirm the rest of the group is healthy:
Terminal window porta_all_group_statusAt least one machine must show
MEMBER_STATEofONLINEandMEMBER_ROLEofPRIMARY. The other surviving machine should beONLINE. -
On the broken machine only, take a manual backup if the database is at least running (even if replication is failing). This is a precaution in case the machine has data the rest of the group does not:
Terminal window porta_backup_db -
On the broken machine, reset its database:
Terminal window porta_reset_db -
Wait for the container to come back up. It will join the existing group and begin replicating data from the surviving machines. The amount of time depends on how much data has to be transferred.
-
Re-check the group:
Terminal window porta_all_group_statusWhen the recovered machine reaches
ONLINE, the restoration is complete.
Multi-node disaster recovery
Section titled “Multi-node disaster recovery”Use this procedure when two or more machines have lost data, or when the entire site has gone down and no machine still holds the authoritative current data.
-
Identify the machine that holds the backup you want to restore from. Ideally this is the machine that has the most recent backup, regardless of role.
-
If any database container on any machine is currently down, start it so its data is accessible. Replication will fail to start, which is expected — only the database service itself needs to be running:
Terminal window docker start porta-db # or porta-db-2, porta-db-3 depending on role -
Take a manual backup on each machine that can be brought up, even if its data is suspect. This is a precaution against losing recoverable transactions:
Terminal window porta_backup_dbBackups live in the
portacontainer, not in the database container, so taking a backup here does not interfere with the reset in the next step. -
Stop each machine’s database container so the next step starts from a clean slate. From each machine:
Terminal window docker stop porta-db # or porta-db-2, porta-db-3 -
On the machine holding the desired backup, reset that machine’s database:
Terminal window porta_reset_db -
Restore from the chosen backup on the same machine:
Terminal window porta_restore_dbWhen prompted, select the backup you identified in step 1.
-
Wait for the restore to complete. This machine is now the authoritative primary.
-
On each of the other machines, reset the database so they will rejoin the new group as fresh members and replicate from the restored primary:
Terminal window porta_reset_db -
Each machine should join the group and begin replicating data from the restored primary. Confirm with:
Terminal window porta_all_group_statusWhen every machine reaches
ONLINE, the restoration is complete.
Failover recovery with Unreal Engine
Section titled “Failover recovery with Unreal Engine”When a PX running Porta fails, the Unreal project rendering on the connected RX needs to be pointed at the backup PX so the show can continue. This is controlled by batch files on the RX desktop.
Total machine failure — power or network loss
Section titled “Total machine failure — power or network loss”If the main PX has completely lost power or network connectivity:
- On the RX, run the desktop batch file
make px2 primary.batto switch the running Unreal project to the backup PX. - Continue the show on the backup PX while the main PX is repaired.
- Once the main PX is recovered, run
make px1 primary.baton the RX to switch back.
Partial machine failure — service or performance loss
Section titled “Partial machine failure — service or performance loss”If the main PX is still running but its socket server is degraded or its performance has dropped:
-
On the failed PX, stop the Porta socket server:
Terminal window docker stop porta-socket -
On the RX, run
make px2 primary.batto switch the running Unreal project to the backup PX. -
Continue the show on the backup PX while the main PX is investigated.
-
When the main PX is healthy again, restart its socket server:
Terminal window docker start porta-socketThen run
make px1 primary.baton the RX to switch back.