2016-06-03 12:01:07 +02:00
|
|
|
# Migration guide
|
|
|
|
Migration is a module for migrating database schema between different version of project [Harbor](https://github.com/vmware/harbor)
|
|
|
|
|
2016-06-03 12:30:02 +02:00
|
|
|
This module is for those machine running Harbor's old version, such as 0.1.0. If your Harbor' version is up to date, please ignore this module.
|
2016-05-09 08:11:34 +02:00
|
|
|
|
|
|
|
**WARNING!!** You must backup your data before migrating
|
|
|
|
|
2016-06-03 12:01:07 +02:00
|
|
|
###Installation
|
2016-06-28 09:48:31 +02:00
|
|
|
- step 1:
|
2016-06-28 10:49:08 +02:00
|
|
|
|
2016-06-28 09:48:31 +02:00
|
|
|
```
|
|
|
|
cd migration
|
|
|
|
```
|
|
|
|
- step 2: change `db_username`, `db_password`, `db_port`, `db_name` in migration.cfg
|
|
|
|
- step 3: build image from dockerfile
|
2016-06-28 10:49:08 +02:00
|
|
|
|
2016-05-09 08:11:34 +02:00
|
|
|
```
|
2016-06-03 12:31:59 +02:00
|
|
|
docker build -t migrate-tool .
|
2016-05-09 08:11:34 +02:00
|
|
|
```
|
|
|
|
|
2016-06-03 12:01:07 +02:00
|
|
|
###Migrate Step
|
2016-06-03 12:30:02 +02:00
|
|
|
- step 1: stop and remove Harbor service
|
2016-06-03 12:01:07 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
docker-compose down
|
|
|
|
```
|
|
|
|
- step 2: create backup file in `/path/to/backup`
|
|
|
|
|
|
|
|
```
|
2016-06-03 12:30:59 +02:00
|
|
|
docker run -ti --rm -v /data/database:/var/lib/mysql -v /path/to/backup:/harbor-migration/backup migrate-tool backup
|
2016-06-03 12:01:07 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
- step 3: perform database schema upgrade
|
|
|
|
|
2016-06-03 12:30:59 +02:00
|
|
|
```docker run -ti --rm -v /data/database:/var/lib/mysql migrate-tool up head```
|
2016-06-03 12:01:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-03 12:30:02 +02:00
|
|
|
- step 4: rebuild newest Harbor images and restart service
|
2016-06-03 12:01:07 +02:00
|
|
|
|
|
|
|
```
|
|
|
|
docker-compose build && docker-compose up -d
|
|
|
|
```
|
|
|
|
|
2016-06-03 12:30:02 +02:00
|
|
|
You may change `/data/database` to the mysql volumes path you set in docker-compose.yml.
|
|
|
|
|
|
|
|
###Migration operation reference
|
2016-06-03 12:31:59 +02:00
|
|
|
- You can use `help` to show instruction of Harbor migration
|
2016-05-09 08:11:34 +02:00
|
|
|
|
2016-06-03 12:01:07 +02:00
|
|
|
```docker run migrate-tool help```
|
2016-05-13 12:05:27 +02:00
|
|
|
|
2016-06-03 12:31:59 +02:00
|
|
|
- You can use `test` to test mysql connection in Harbor migration
|
2016-05-13 12:05:27 +02:00
|
|
|
|
2016-06-03 12:30:59 +02:00
|
|
|
```docker run --rm -v /data/database:/var/lib/mysql migrate-tool test```
|
2016-05-09 08:11:34 +02:00
|
|
|
|
2016-06-03 12:30:02 +02:00
|
|
|
- You can restore from backup file in `/path/to/backup`
|
2016-05-09 08:11:34 +02:00
|
|
|
|
|
|
|
```
|
2016-06-03 12:30:59 +02:00
|
|
|
docker run -ti --rm -v /data/database:/var/lib/mysql -v /path/to/backup:/harbor-migration/backup migrate-tool restore
|
2016-05-09 08:11:34 +02:00
|
|
|
```
|