Adds migration script

This commit is contained in:
Maximilian Kratz 2023-03-28 18:18:08 +02:00
parent b30bb8e355
commit d52e555c7b

34
s3-migration/migrate-s3.sh Executable file
View file

@ -0,0 +1,34 @@
#!/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 alias set s3trg $TARGET $ACCESSKEY $SECRETKEY
mc admin config export s3src > config.txt
mc admin config import s3trg < config.txt
mc admin service restart s3trg
mc admin cluster bucket export s3src
mc admin cluster bucket import s3trg cluster-metadata.zip
# mirroring
mc mirror -preserve --watch s3src/gitea s3trg/gitea