Hi,
The forgejo migrate-storage command has a --help listing in the Forgejo CLI page, but no real documentation on how to use it. The Storage settings describes how to configure the [storage] section, but not how to move existing data when updating the [storage] section.
I did a storage migration today, and I think some docs would have made it a bit smoother. Fortunately, I've been through this process with gitea once previously, so I was able to get through it again. But I would have loved some step-by-step instructions and examples.
As a potential starting point for that, I will describe what I did:
- made the decision to move local storage to minio/s3
- took stock of what was currently in local storage (for me, it's all packages, actions_log, and a few avatars)
- created a forgejo bucket, a user that has access to it, and an access key/secret key
- added a commented-out
[storage] section with STORAGE_TYPE = minio and the necessary minio settings, to my config file
- shelled into the forgejo container, looked at the
forgejo migrate-storage --help output
- mapped those settings to the corresponding parameters, with the help of the "Storage settings" page
- ran a shell loop to migrate each data type to s3
- uncommented the
[storage] section of the config, restarted forgejo
- verified that packages, avatars, etc are still available
It took me some trial and error to get the right command for step 7. Here's what I ended up with:
for STORAGETYPE in attachments lfs avatars repo-avatars repo-archivers packages actions-log actions-artifacts; do
forgejo migrate-storage --storage=minio [bucket, endpoint, ssl, key settings] --type=$STORAGETYPE --minio-base-path=$STORAGETYPE/
done
And here are the places I stumbled, along the way:
- I needed to add
--user=git to my docker exec forgejo bash command, because it doesn't like to run as the root user.
- I assumed (incorrectly) that omitting the
--type value would cause it to migrate EVERY type. It did not; it instead gave me an unclear error message Command error: unsupported storage:, which made me wonder if my s3-compatible server was not actually s3-compatible.
- I briefly hoped that the
--type value would accept a comma-separated list of types. It did not.
- I assumed (incorrectly) that
forgejo migrate-storage command would apply the same path prefixes that the [storage] configuration section would... meaning packages go under packages/, avatars under avatars/, etc. It did not. Instead, everything went to the root of the bucket, in a jumbled mess. I had to remove it all and start over with specified base paths.
In the end, it all worked. But is this the intended usage? It took me a while to get there.
Thanks!
Hi,
The `forgejo migrate-storage` command has a `--help` listing in [the Forgejo CLI page](https://forgejo.org/docs/latest/admin/command-line/#migrate-storage), but no real documentation on how to use it. The [Storage settings](https://forgejo.org/docs/latest/admin/storage/) describes how to configure the `[storage]` section, but not how to move existing data when updating the `[storage]` section.
I did a storage migration today, and I think some docs would have made it a bit smoother. Fortunately, I've been through this process with gitea once previously, so I was able to get through it again. But I would have loved some step-by-step instructions and examples.
As a potential starting point for that, I will describe what I did:
1. made the decision to move local storage to minio/s3
2. took stock of what was currently in local storage (for me, it's all packages, actions_log, and a few avatars)
3. created a forgejo bucket, a user that has access to it, and an access key/secret key
4. added a commented-out `[storage]` section with `STORAGE_TYPE = minio` and the necessary minio settings, to my config file
5. shelled into the forgejo container, looked at the `forgejo migrate-storage --help` output
6. mapped those settings to the corresponding parameters, with the help of the "Storage settings" page
7. ran a shell loop to migrate each data type to s3
8. uncommented the `[storage]` section of the config, restarted forgejo
9. verified that packages, avatars, etc are still available
It took me some trial and error to get the right command for step 7. Here's what I ended up with:
```shell
for STORAGETYPE in attachments lfs avatars repo-avatars repo-archivers packages actions-log actions-artifacts; do
forgejo migrate-storage --storage=minio [bucket, endpoint, ssl, key settings] --type=$STORAGETYPE --minio-base-path=$STORAGETYPE/
done
```
And here are the places I stumbled, along the way:
1. I needed to add `--user=git` to my `docker exec forgejo bash` command, because it doesn't like to run as the root user.
2. I assumed (incorrectly) that omitting the `--type` value would cause it to migrate *EVERY* type. It did not; it instead gave me an unclear error message `Command error: unsupported storage:`, which made me wonder if my s3-compatible server was not actually s3-compatible.
3. I briefly hoped that the `--type` value would accept a comma-separated list of types. It did not.
4. I assumed (incorrectly) that `forgejo migrate-storage` command would apply the same path prefixes that the `[storage]` configuration section would... meaning packages go under `packages/`, avatars under `avatars/`, etc. It did not. Instead, everything went to the root of the bucket, in a jumbled mess. I had to remove it all and start over with specified base paths.
In the end, it all worked. But is this the intended usage? It took me a while to get there.
Thanks!