Moving Azure Blobs to Oracle Cloud Infrastructure Object Storage Service using RClone (Azure Blob to OCI OSS)
rclone scripts to migrate content from azure to oci
This repo contents some useful scripts to migrate data from Azure Blob to Oracle Cloud Infrastructure Object Storage Service (OCI-OSS)
- OCI or Azure VM with 24OCPUs / VCPs and with At-least 128GB RAM and 1 TB HDD
- az cli
- oci cli
- rclone
You will must have following limits on /etc/security/limits.conf
* soft nproc 4096
root soft nproc unlimited
root soft nproc 65000
root hard nproc 65000
root hard nofile 65000
Also read following links as well
https://project-sunbird.atlassian.net/browse/ED-462 project-sunbird/sunbird-devops#3605 (Yes I am originally doing this for sunbird)
To install rclone on Linux/macOS/BSD systems, run:
sudo -v ; curl https://rclone.org/install.sh | sudo bash
Follwing Should be installed under root (sudo su - or sudo -i ) and please make sure to delete your compute after migration done.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
and continue as per the installation instructions. Just press enter until the end if you are new to this or no need any customizations :-D
bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
and continue as per the installation instructions. Just press enter until the end if you are new to this or no need any customizations :-D
run following command to login to az cli and then do as per console instructions. command will exit upon the successful login.
az login
rul following command to setup oci cli
oci setup config
run following command to login to az cli and then do as per console instructions. command will exit upon the successful login. Or read following to setup instance principal https://www.ateam-oracle.com/post/calling-oci-cli-using-instance-principal to the instance (Only applicable if you are creating the instance on OCI and not valid for azure)
RClone can be configured using following command but I am adding the required config for rclone v1.61.1 just to make your life easy
rclone config
make sure to have following alike config under the path "/root/.config/rclone/rclone.conf" (yes need root account)
[azure]
type = azureblob
env_auth = true
[oci]
type = oracleobjectstorage
namespace = axdTRUNCATEDixb
compartment = ocid1.compartment.oc1..aaaaaaaahnnivgp2mTRUNCATED6itp2cwmkhb7doa
region = ap-mumbai-1
basically I have given azure and oci as the names for the 2 CSP configurations. You may add any blocks as you may need.
You need to create buckets on OCI Side before doing the migration. So what I have done is to create a script to list containers inside given set of azure storage account and create those on oci oss.
Please remember that OCI do not have storage account concept and you cannot have duplicate name for buckets even inside oci compartments. So you will have to handle that issue with prefixing storage account name to the oci side bucket. (Need only if you have 2 containers with same name amoung multiple storage accounts. For ex production and testing storage accounts can have a container named config)
#!/bin/bash
#set path for az / oci binary
export PATH=$PATH:/root/bin/
# To Get a list of storage accounts execute following command
#storage_accounts=$(az storage account list --output tsv --query '[].name')
#Now select required storage accounts
storage_accounts="production dev testing"
#Provide OCI Compartment to Create new buckets
oci_compartment_id='ocid1.compartment.oc1..aaaaaaaahnnivTRUNCATeD'
# Iterate through each storage account
for storage_account in $storage_accounts; do
# Get a list of all containers in the storage account
containers=$(az storage container list --account-name $storage_account --num-results "*" --output tsv --query '[].name')
# Iterate through each container
for container in $containers; do
#create oci bucket as per the template [Storage_Account_Name]-[Container_Name]
oci os bucket create --name "$storage_account-$container" --compartment-id $oci_compartment_id 2>&1 >> oci_os_creation.log
done
done
I have tested above to create 196000+ buckets and it took around 2 days. This is thanks to the az cli / api list limits "single listing call is 5000."
This is simple but please make sure to have a screen
session to run script
follwing script designed to take az storage account container and oci oss buckets as command line arguments
#!/bin/bash
export PATH=$PATH:/root/bin/
#azure to oci sync
export AZURE_STORAGE_ACCOUNT_NAME=$1
/root/rclone -vvv --progress --stats-one-line --multi-thread-streams 8 --transfers 5000 --buffer-size 48Mi --azureblob-list-chunk 5000 --max-stats-groups 10 --oos-chunk-size 100Mi --oos-upload-concurrency 10000 --retries 3 --checkers 32 --size-only sync azure:$2 oci:$3
#./azure_to_oci_sync.sh [azure_storage_account] [azure-container] [oci-bucket-name]
./azure_to_oci_sync.sh production config-container production-config-container