| # 22. Maintenance db4o is designed to minimize maintenance tasks to the absolute minimum. The stored class schema adapts to the application automatically as it is being developed. db4o "understands" the addition and removal of fields which allows it to continue to work against modified classes without having to reorganize the database file. Internally db4o works with a superset of all class versions previously used. However there are two recommended maintenance tasks, that can both be fully automated remotely with API calls: ## 22.1. Defragment Defragment creates a new database file and copies all objects from the current database file to the new database file. All indexes are recreated. The resulting database file will be smaller and faster. com.db4o.tools.Defragment is only supplied as source code to encourage embedding custom maintenance tasks on objects. ## 22.2. Backup db4o supplies hot backup functionality to backup single-user databases and client-server databases while they are running. The respective API calls for backups are:
`objectContainer.ext().backup(String path)`
`objectServer.ext().backup(String path)`
The methods can be called while an ObjectContainer/ObjectServer is open and they will execute with low priority in a dedicated thread, with as little impact on processing performance as possible. It is recommended to backup the current development state of an application (ideally source code and bytecode) along with the database files since the old code can make it easier to work with the old data. -- generated by Doctor courtesy of db4objects Inc.