All Products
Search
Document Center

Object Storage Service:How do I restore multiple objects at a time?

Last Updated:Mar 20, 2026

The OSS console restores one object at a time and does not support bulk restoration within a folder. To restore multiple Archive objects at once, use ossutil, the OSS API, or the OSS SDK.

If you enabled real-time access of Archive objects, restoration is not required before accessing those objects.

Prerequisites

Before you begin, make sure that you have:

  • An OSS bucket containing Archive objects

  • ossutil installed and configured, or access to the OSS SDK or OSS API

Restore multiple Archive objects

Restoring multiple Archive objects involves three steps: list the objects, filter those with Archive storage class, then restore them in bulk.

Step 1: List objects in the bucket

Choose one of the following methods:

  • Bucket inventory (recommended): Export an inventory list of all objects in the bucket. This approach is efficient and cost-effective for large buckets. See Bucket inventory.

  • ListObjects API: Call the ListObjects operation to retrieve objects programmatically. This incurs higher API call fees than inventory-based listing. See List objects and API operation calling fees.

Step 2: Filter Archive objects and record their paths

If you used bucket inventory: Filter rows where StorageClass is Archive in the inventory CSV. Record the full object path for each match, excluding the bucket name.

If you used the OSS SDK: Use the Key and StorageClass fields from the list response to identify Archive objects and their paths. For example, in Java:

System.out.println("fileurl" + s.getKey() + "&stu:" + s.getStorageClass());

Step 3: Restore the objects

Choose the method that best fits your workflow:

MethodBest forNotes
ossutilCommand-line usersSimplest and fastest to run
OSS SDKApplications requiring code reuseMore complex to set up; requires a build tool
OSS APIHigh-customization applicationsNo batch operation; call RestoreObject once per object; requires manual signature calculation

For general restoration steps and background, see Restore objects.

Restore with ossutil

ossutil is simpler and more efficient to use compared with the other methods, if you are familiar with command line operations. For usage details, see Restore objects.

Restore with the OSS SDK (Java example)

The sample code in the Restore objects topic restores a single object. To restore multiple objects, replace the objectName variable with a list of object paths, as shown below.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.model.*;

import java.util.ArrayList;
import java.util.List;

public class Demo {
    public static void main(String[] args) throws Exception {
        // Specify the endpoint for your bucket's region.
        String endpoint = "oss-cn-beijing.aliyuncs.com";
        // Specify the region ID. Example: cn-hangzhou.
        String region = "cn-hangzhou";
        // Load credentials from environment variables.
        // Set OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET before running this code.
        EnvironmentVariableCredentialsProvider credentialsProvider =
            CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the bucket name.
        String bucketName = "examplebucket";
        // Add the full paths of the Archive objects to restore.
        // Do not include the bucket name in the paths.
        List<String> filePaths = new ArrayList<>();
        filePaths.add("filePath1");
        filePaths.add("filePath2");

        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        // Use V4 signature.
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {
            for (String filePath : filePaths) {
                ObjectMetadata objectMetadata = ossClient.getObjectMetadata(bucketName, filePath);
                // Restore only if the object is Archive class.
                StorageClass storageClass = objectMetadata.getObjectStorageClass();
                if (storageClass == StorageClass.Archive) {
                    ossClient.restoreObject(bucketName, filePath);
                }
                System.out.println(filePath + " start thawing.");
            }
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

Verify the restoration status

To check whether your objects have been successfully restored, see How do I check whether OSS objects are restored?

For Cold Archive or Deep Cold Archive objects, the restore process differs. See the Overview page and navigate to the corresponding Restore objects topic.

What's next