For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/en/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/en/llms-full.txt, and this page is available as Markdown at https://docs.ovhcloud.com/en/guides/storage-and-backup/object-storage/pcs-sync-object-containers.md.

Object Storage Swift - Syncing object containers

View as Markdown

Objective

If you want to move your objects from one data centre to another, or even from one project to another, syncing objects between containers is the best solution for avoiding service disruptions during your migration. This guide explains how you can implement this solution.

Requirements

Instructions

Info

If your container contains objects larger than 5 GB, your two containers must have the same name. In addition, the synchronisation configuration must also be applied to the container that contains the segments.

Configuring the sync

Creating a sync key

For containers to authenticate, you will need to create a key and configure it on each object container.

  • Create the key:
root@server-1:~$ sharedKey=$(openssl rand -base64 32)

Destination container configuration

First of all, you will need to configure the key on the container that will receive the data. In our case, the destination container is in BHS.

  • Check the region that has loaded in the environment variables:
root@server-1:~$ env | grep OS_REGION

OS_REGION_NAME=BHS
  • Configure the key on the destination container:
root@server-1:~$ swift post --sync-key "$sharedKey" containerBHS
  • Next, check that the key has been successfully configured using the following command, and note down the content of the "Account" variable at the same time:
root@server-1:~$ swift stat containerBHS
                         Account: AUTH_b3e269xxxxxxxxxxxxxxxxxxxx2b0ba29
                       Container: containerBHS
                         Objects: 0
                           Bytes: 0
                        Read ACL:
                       Write ACL:
                         Sync To:
                        Sync Key: 4cA5j5LyaaG2ws32d1fsdQSxnvIJv+y2qFnbnm6Kw=
Meta Access-Control-Allow-Origin: https://www.ovh.com
                   Accept-Ranges: bytes
                X-Storage-Policy: Policy-0
                      Connection: close
                     X-Timestamp: 1444812373.28095
                      X-Trans-Id: B2210C05:895E_9E45A961:01BB_561E52E1_16A3:5298
                    Content-Type: text/plain; charset=utf-8
  • Retrieve the target container’s address, then configure it on the source container (this one is: //OVH_PUBLIC_CLOUD/Region/Account/Container).
root@server-1:~$ export destContainer="//OVH_PUBLIC_CLOUD/BHS/AUTH_b3e269xxxxxxxxxxxxxxxxxxxx2b0ba29/containerBHS"

Source container configuration

  • Change the region in the environment variables:
root@server-1:~$ export OS_REGION_NAME=GRA
  • Configure the key on the source container:
root@server-1:~$ swift post --sync-key "$sharedKey" containerGRA
  • Configure the recipient container on the source container:
root@server-1:~$ swift post --sync-to "$destContainer" containerGRA
  • As detailed previously, you can check that it has been configured properly using the following command:
root@server-1:~$ swift stat containerGRA
         Account: AUTH_b3e269xxxxxxxxxxxxxxxxxxxx2b0ba29
       Container: containerGRA
         Objects: 3
           Bytes: 15
        Read ACL:
       Write ACL:
         Sync To: //OVH_PUBLIC_CLOUD/BHS/AUTH_b3e269xxxxxxxxxxxxxxxxxxxx2b0ba29/containerBHS
        Sync Key: 4cA5j5LyaaG2wU4lDYnDmEwQSxnvIJv+y2qFnbnm6Kw=
   Accept-Ranges: bytes
      Connection: close
     X-Timestamp: 1444813114.55493
      X-Trans-Id: B2210C05:879E_052711B1:01BB_561E559B_24AE:6B1B
X-Storage-Policy: Policy-0
    Content-Type: text/plain; charset=utf-8

Checking the sync

After a few minutes (depending on the number and size of the files to be sent), you can check whether the sync is successful by simply listing the files in each container.

  • To list the files on the source container:
root@server-1:~$ swift list containerGRA
test1.txt
test2.txt
test3.txt
  • To list the files on the destination container:
root@server-1:~$ swift list containerBHS
test1.txt
test2.txt
test3.txt

Reversing the synchronisation between two containers

In order to reverse the synchronisation between two containers, you need to remove the --sync-to metadata from the source container, and redeclare it on the other container, which will then become the new source container.

Warning

Don't forget to also change the region in the new "sync-to" URL.

root@server-1:~$ swift post -H "X-Container-Sync-To:" containerGRA
root@server-1:~$ export destContainer="//OVH_PUBLIC_CLOUD/GRA/AUTH_b3e269xxxxxxxxxxxxxxxxxxxx2b0ba29/containerGRA"
root@server-1:~$ export OS_REGION_NAME=BHS
root@server-1:~$ swift post --sync-to "$destContainer" containerBHS

Stop synchronisation between two containers

In order to stop synchronisation between two containers, you need to remove the --sync-key and --sync-to metadata:

swift post -H "X-Container-Sync-Key:" containerGRA
swift post -H "X-Container-Sync-To:" containerGRA
Info

You can also use this guide for migrating RunAbove objects to the OVHcloud Public Cloud.

Go further

For training or technical assistance implementing our solutions, contact your sales representative or visit our Professional Services page to request a quote and have your project analysed by our experts.

Join our community of users.

Was this page helpful?