diff --git a/.gitignore b/.gitignore index 40a3359..f1ee8ec 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,5 @@ vars/woodpecker_production.yml vars/woodpecker_staging.yml vars/backup.yml + +s3-migration/local-storage/ diff --git a/s3-migration/MIGRATION.md b/s3-migration/MIGRATION.md index 49dd077..c5d31d7 100644 --- a/s3-migration/MIGRATION.md +++ b/s3-migration/MIGRATION.md @@ -11,6 +11,8 @@ Steps (in theory): - Re-deploy a new instance with the new backend version to replace the old instance - Migrate metadata + bucket data from temporary instance to the new instance +Please notice: `mc` copies the whole data over the network. Due to slow speeds at home/office, it is recommend to run the migration on one of the servers. + ## Commands/Steps to run diff --git a/s3-migration/install-mc.sh b/s3-migration/install-mc.sh new file mode 100755 index 0000000..583e339 --- /dev/null +++ b/s3-migration/install-mc.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +curl https://dl.min.io/client/mc/release/linux-amd64/mc \ + --create-dirs \ + -o $HOME/minio-binaries/mc + +chmod +x $HOME/minio-binaries/mc +export PATH=$PATH:$HOME/minio-binaries/ diff --git a/s3-migration/migrate-s3_local.sh b/s3-migration/migrate-s3_local.sh new file mode 100755 index 0000000..cbb6967 --- /dev/null +++ b/s3-migration/migrate-s3_local.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +# Check for existing ENVs +if [[ -z "$ACCESSKEY" ]]; then + echo "=> No ACCESSKEY ENV found. Exit."; exit 1 ; +fi + +if [[ -z "$SECRETKEY" ]]; then + echo "=> No SECRETKEY ENV found. Exit."; exit 1 ; +fi + +if [[ -z "$SOURCE" ]]; then + echo "=> No SOURCE ENV found. Exit."; exit 1 ; +fi + +if [[ -z "$TARGET" ]]; then + echo "=> No TARGET ENV found. Exit."; exit 1 ; +fi + +mc alias set s3src $SOURCE $ACCESSKEY $SECRETKEY + +mc mirror -preserve --watch s3src/gitea $TARGET diff --git a/s3.yaml b/s3.yaml index 9c05bb0..d16eab2 100644 --- a/s3.yaml +++ b/s3.yaml @@ -2,9 +2,9 @@ - name: Check SSH port import_playbook: ssh.yaml - name: (Re-)Deploy Minio S3 - hosts: staging + hosts: all roles: - minio-dc become: true vars: - instance_url: "{{staging_url}}" + instance_url: "{{prod_url}}"