How to backup and restore nexus with Nexus
TOC
PrerequisitesBackupCreate a backup task on Nexus web.Remove the nexus instance service to prevent data changes during backupBackup nexus data and verify the backupBackup blob storageBackup node ID keystoreExport and back up the databaseVerify backup contentsAfter Successful Backup, Restore the nexus instance serviceRestorePrerequisitesUninstall Nexus ce operator from the cluster if not done already.Remove the nexus instance service to prevent data changes during restoreRemove existing data from the target instanceRestart the pod to let Nexus restore from backup.Import backup dataRestart pod to restoreClean up temporary data and restore normal service.TroubleshootingBackup task fails with AccessDeniedExceptionPrerequisites
Uninstall the Nexus operator from the cluster.
Why uninstall the Nexus operator?
During backup and restore, the Operator may reconcile Nexus resources and interfere with the process. If the Operator is not uninstalled, the following issues may occur:
- The Operator may recreate or restart workloads based on the Nexus CR, interrupting the backup/restore procedure and potentially causing data inconsistency.
- Some resources you temporarily remove (e.g.,
Service) might be recreated, or conflict with resources restored from backup (e.g.,Ingress).
Impact of uninstalling the Nexus operator
After uninstalling the Operator, modifications to the Nexus CR will not take effect, such as adjusting resources or storage size.
Uninstalling the Operator will not cause existing instances to malfunction.
Backup
Backup consists of four steps:
- Create a backup task on Nexus web.
- Remove the nexus instance service to prevent data changes
- Backup nexus data and verify the backup.
- Restore nexus instance after the backup end.
Create a backup task on Nexus web.
Login to Nexus web UI as an admin user. Navigate to Settings -> System -> Tasks -> Create task -> Select Admin - Backup H2 Database, input:
- Task enabled: true
- Task name: nexus-backup (or any name you like)
- Notification email: (optional) user@example.com
- Send Notification on: (optional) Failure
- Location: any subdirectory under
/nexus-data(e.g.,/nexus-data/backup-dir) - Task frequency: Manual
Remove the nexus instance service to prevent data changes during backup
To prevent writes during backup, temporarily stop the service endpoint to the instance by deleting the Service that fronts the pod(s):
This does not delete the pod or data; it only stops external traffic.
Backup nexus data and verify the backup
Backup blob storage
Backup node ID keystore
Export and back up the database
Then copy the exported files from the pod:
Verify backup contents
After completing the copy, the backup directory should contain at least the following folders:
nexus-backup/blobsnexus-backup/nodenexus-backup/restore-from-backup
You may see different file names inside these directories depending on your instance.
After Successful Backup, Restore the nexus instance service
Go to the Administrator -> Marketplace -> Operator Hub page, switch to the target cluster, and then redeploy the Alauda Build of Nexus Operator.
Restore
Prerequisites
Decide the target namespace and whether you will restore into the original instance (overwriting data) or into a new instance. Ensure the Operator remains uninstalled during the restore to avoid interference.
Restoration consists of five steps:
- Uninstall Nexus ce operator from the cluster if not done already.
- Remove the nexus instance service to prevent data changes during restore.
- Remove existing data from the target instance.
- Restart the pod to let Nexus restore from backup.
- Clean up temporary data and restore normal service.
Uninstall Nexus ce operator from the cluster if not done already.
Remove the nexus instance service to prevent data changes during restore
Remove existing data from the target instance
Delete the existing data from the target pod to avoid mixing old and restored data. If permissions prevent deletion inside the pod, remove the data directly from the mounted volume according to your storage class instructions.
If you must delete on the node/PV directly, remove the same directories there.
Restart the pod to let Nexus restore from backup.
Import backup data
Verify the following directories in the pod contain data:
/nexus-data/blobs/nexus-data/keystores/node/nexus-data/restore-from-backup
Restart pod to restore
Wait for the new pod to start and for Nexus to complete its internal restore process.
Clean up temporary data and restore normal service.
After confirming data has been restored and the instance works as expected, remove the temporary restore files to avoid repeated imports on future restarts:
Go to the Administrator -> Marketplace -> Operator Hub page, switch to the target cluster, and then redeploy the Alauda Build of Nexus Operator.
Login in Nexus Web, check that all repositories and data are intact.
Troubleshooting
Backup task fails with AccessDeniedException
when checking the task status, if you see the lastRunResult is FAILED:
you can check the task log for more details:
This indicates that Nexus does not have permission to write to the specified backup location. Ensure that the backup directory under /nexus-data.
Go to the Administrator -> Marketplace -> Operator Hub page, switch to the target cluster, and then redeploy the Alauda Build of Nexus Operator, and Navigate to nexus web, modify the backup task to use a directory under /nexus-data, such as /nexus-data/backup.