infrastructure-as-code/s3-migration/migrate-s3.sh

35 lines
805 B
Bash
Raw Permalink Normal View History

2023-03-28 16:18:08 +00:00
#!/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
2023-03-29 04:49:22 +00:00
# mirroring existing bucket -> migration server/bucket
2023-03-28 16:18:08 +00:00
mc mirror -preserve --watch s3src/gitea s3trg/gitea