Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Last active August 29, 2024 11:33
Show Gist options
  • Save icyleaf/e2d3a0698da853b026801fd92c655920 to your computer and use it in GitHub Desktop.
Save icyleaf/e2d3a0698da853b026801fd92c655920 to your computer and use it in GitHub Desktop.
Gitea migrate storage from local to minio auto script

Gitea migrate storage script

This is based on offically cli tool built-in subcommand calls migrate-storage.

#!/usr/bin/env bash
MINIO_ENDPOINT=localhost:8080
MINIO_USE_SSL=false
MINIO_SSL_INSECURE_VERIFY=false
MINIO_ACCESS_KEY=123
MINIO_SECRET_KEY=456
MINIO_BUCKET=gitea
GITEA_MIGRATE_TYPES=(attachments lfs avatars repo-avatars repo-archivers packages actions-log)
for type in "${GITEA_MIGRATE_TYPES[@]}"; do
minio_base_path=${type//-/_}
echo "Migrating ${type} ..."
gitea migrate-storage --type=${type} \
--storage=minio \
--minio-endpoint=${MINIO_ENDPOINT} \
--minio-access-key-id=${MINIO_ACCESS_KEY} \
--minio-secret-access-key=${MINIO_SECRET_KEY} \
--minio-bucket=${MINIO_BUCKET} \
--minio-base-path=${minio_base_path}/ \
--minio-use-ssl=${MINIO_USE_SSL} \
--minio-insecure-skip-verify=${MINIO_SSL_INSECURE_VERIFY}
done
@GhaziTriki
Copy link

Here some updates,

Need to run with git user sudo -u git gitea --config=/etc/gitea/app.ini migrate-storage and put the config path.

And more types to migrate

GITEA_MIGRATE_TYPES=(attachments lfs avatars repo-avatars repo-archivers packages actions-log actions-artifacts)

However I got : Command error: permission denied. Any help @icyleaf ?

Here complete logs

2024/08/29 12:31:03 ...d/migrate_storage.go:192:runMigrateStorage() [I] AppPath: /usr/local/bin/gitea
2024/08/29 12:31:03 ...d/migrate_storage.go:193:runMigrateStorage() [I] AppWorkPath: /var/lib/gitea
2024/08/29 12:31:03 ...d/migrate_storage.go:194:runMigrateStorage() [I] Custom path: /var/lib/gitea/custom
2024/08/29 12:31:03 ...d/migrate_storage.go:195:runMigrateStorage() [I] Log path: /var/lib/gitea/log
2024/08/29 12:31:03 ...d/migrate_storage.go:196:runMigrateStorage() [I] Configuration file: /etc/gitea/app.ini
2024/08/29 12:31:03 [email protected]/command.go:272:Run() [I] PING DATABASE postgres
2024/08/29 12:31:04 [email protected]/command.go:272:Run() [W] Table oauth2_application Column confidential_client db default is true, struct default is TRUE
2024/08/29 12:31:04 [email protected]/command.go:272:Run() [W] Table system_setting Column version db default is , struct default is 1
2024/08/29 12:31:04 [email protected]/command.go:272:Run() [W] Table user Column max_repo_creation db default is '-1', struct default is -1
2024/08/29 12:31:04 [email protected]/command.go:272:Run() [W] Table label Column archived_unix db default is , struct default is NULL
2024/08/29 12:31:04 ...s/storage/storage.go:176:initAttachments() [I] Initialising Attachment storage with type: minio
2024/08/29 12:31:04 ...les/storage/minio.go:86:NewMinioStorage() [I] Creating Minio storage at s3.domain.tld:gitea with base path attachments/
Command error: permission denied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment