Skip to content

Backup Restoration

Restoring a backup

Restoration Steps

MCDR Environment

Prime Backup currently only supports backup restoration in MCDR environment

To restore a backup in MCDR environment, simply execute the following command:

!!pb back

This command will restore to the latest non-temporary backup. To restore to a specific backup, you can specify the backup ID:

!!pb back 78

Example console output:

> !!pb back 78
[MCDR] [22:08:24] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] Gonna restore the world to backup #78: Test Backup
[MCDR] [22:08:24] [PB@f133-worker-heavy/INFO]: [PB] Please choose and enter command within 1 minute:
[MCDR] [22:08:24] [PB@f133-worker-heavy/INFO]: [PB] - Confirm restore√: !!pb confirm
[MCDR] [22:08:24] [PB@f133-worker-heavy/INFO]: [PB] - Abort restore×: !!pb abort
> !!pb confirm
[MCDR] [22:08:26] [TaskExecutor/INFO]: [PB] Confirming restore backup task
[MCDR] [22:08:26] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 10 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:27] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 9 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:28] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 8 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:29] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 7 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:30] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 6 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:31] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 5 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:32] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 4 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:33] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 3 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:34] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 2 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:35] [PB@f133-worker-heavy/INFO] [prime_backup]: [PB] !!! 1 second later, the world will be restored to backup #78: Test Backup
[MCDR] [22:08:36] [PB@f133-worker-heavy/INFO] [prime_backup]: Wait for server to stop
[Server] [22:08:36] [Server thread/INFO]: Stopping the server
[Server] [22:08:36] [Server thread/INFO]: Stopping server
[Server] [22:08:36] [Server thread/INFO]: Saving players
[Server] [22:08:36] [Server thread/INFO]: Saving worlds
[Server] [22:08:36] [Server thread/INFO]: Saving chunks for level 'world'/minecraft:the_nether
[Server] [22:08:36] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[Server] [22:08:36] [Server thread/INFO]: Saving chunks for level 'world'/minecraft:the_end
[Server] [22:08:36] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Server] [22:08:36] [Server thread/INFO]: Saving chunks for level 'world'/minecraft:overworld
[Server] [22:08:37] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[Server] [22:08:37] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[Server] [22:08:37] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[Server] [22:08:37] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[MCDR] [22:08:37] [MainThread/INFO]: Server process stopped with code 0
[MCDR] [22:08:37] [MainThread/INFO]: Server stopped
[MCDR] [22:08:37] [PB@f133-worker-heavy/INFO] [prime_backup]: Creating backup of existing files to avoid idiot
[MCDR] [22:08:37] [PB@f133-worker-heavy/INFO] [prime_backup]: Scanning file for backup creation at path 'server', targets: ['world']
[MCDR] [22:08:38] [PB@f133-worker-heavy/INFO] [prime_backup]: Creating backup for ['world'] at path 'server', file cnt 4118, timestamp 1765128818483891, creator 'prime_backup:pre_restore', comment '__pb_translated__:pre_restore:78', tags {'temporary': True}
[MCDR] [22:08:39] [PB@f133-worker-heavy/INFO] [prime_backup]: Create backup #83 done, +5 blobs (size 6.42MiB / 7.27MiB)
[MCDR] [22:08:39] [PB@f133-worker-heavy/INFO] [prime_backup]: Restoring to backup #78 (fail_soft=False, verify_blob=True)
[MCDR] [22:08:39] [PB@f133-worker-heavy/INFO] [prime_backup]: Exporting Backup(id=78, timestamp=1763890381206484, creator='player:Fallen_Breath', comment='Test Backup', targets=['world'], tags={}, fileset_id_base=56, fileset_id_delta=88, file_count=4118, file_raw_size_sum=136177532, file_stored_size_sum=78537902) to directory server
[MCDR] [22:08:48] [PB@f133-worker-heavy/INFO] [prime_backup]: Export done
[MCDR] [22:08:48] [PB@f133-worker-heavy/INFO] [prime_backup]: Restore to backup #78 done, cost 10.3s (backup 1.79s, restore 8.51s), starting the server
[MCDR] [22:08:48] [PB@f133-worker-heavy/INFO]: Starting the server with command 'java -Xms1G -Xmx2G -jar server.jar'

Example in-game output:

pb back

The restore command supports multiple backup ID formats:

Format Example Description
Positive integer !!pb back 12 Restore to backup with specified ID
~ or latest !!pb back ~ Restore to latest non-temporary backup
Relative offset !!pb back ~1 Restore to the backup before the latest backup
Relative offset !!pb back ~3 Restore to the backup three before the latest backup

The restore command supports the following optional parameters:

Parameter Description
--confirm Skip confirmation step, directly start restoration
--fail-soft Skip files that fail to export during export process
--no-verify Do not verify the content of exported files

Example:

!!pb back 12 --confirm --fail-soft

Command Line Environment

Prime Backup currently does not support restoring backups in command line environment (maybe next time!)

Configuration related to restoration is mainly located in the following two sections:

Detailed Restoration Process

Below will list the operation process during PB backup restoration

  1. Confirmation phase
  2. Display the backup information to be restored
  3. Wait for user confirmation (unless using --confirm parameter)
  4. User can confirm with !!pb confirm or abort with !!pb abort
  5. Server shutdown
  6. If the server is running, execute 10s countdown (default configuration command.restore_countdown_sec: 10)
  7. Restoration can be canceled during countdown
  8. Stop the server and wait for complete shutdown
  9. Pre-restoration backup
  10. If backup_on_restore is configured (default value true), create a backup at this time for emergency use
  11. Backup comment is "Automatic backup before restoring to #X"
  12. This backup will be marked as temporary and will be specially handled during backup cleanup
  13. Actual restoration operation
  14. Recycle bin mechanism: Move all existing files in the backup target directory to a temporary recycle bin, ensuring complete rollback if restoration fails
  15. Retain file processing: If retain_patterns is configured, use gitignore-style pattern matching and isolate files to be retained
  16. File export: Use multi-threading to export backup files to the target directory in parallel
  17. Attribute restoration: Restore file permissions, timestamps, owners, and symbolic link targets
  18. Retain file restoration: Finally move retain_patterns retained files back to their original positions
  19. Server restart
  20. If the server was originally running, restart the server