Restore Workspace Backup

Restore the specified workspace from the specified backup.

REQUEST URI

https://<ZohoAnalytics_Server_URI>/restapi/v2/workspaces/<workspace-id>/backups/<backup-id>/restore

Post

oauthscope: ZohoAnalytics.metadata.create

QUERY PARAMETERS

 

Parameter Name
Description
CONFIG*JSONObject
Config parameter specifications are available in the below section.

FIELDS FOR CONFIG JSON

 

Key
Description
confirmRestore*Boolean
Confirms the restore of the workspace from the specified backup.
Supported value: "true"
This attribute is mandatory and must be set to true to proceed with the restore.

Sample: {"confirmRestore":true}
restoreModeString
The mode of the restore.
Supported values: "STRUCTURE_AND_DATA", "STRUCTURE"
STRUCTURE_AND_DATA - Restores the workspace structure and all row data.
STRUCTURE - Restores only the workspace structure, without row data.
The values are case-sensitive.
Maximum length - 100 characters.
Default value - the mode of the selected backup.
A STRUCTURE_AND_DATA backup can be restored as STRUCTURE. A STRUCTURE backup cannot be restored as STRUCTURE_AND_DATA.

Sample: {"restoreMode":"STRUCTURE_AND_DATA"}

Note: Restoring a backup overwrites the current structure of the workspace, and also its data when the restore mode is STRUCTURE_AND_DATA.

Note: The restore runs in the background. Use the Get Restore Status by Restore Reference ID API to track its completion.

Sample Request:

Copiedcurl "https://analyticsapi.zoho.com/restapi/v2/workspaces/<workspace-id>/backups/<backup-id>/restore" \
  -X 'POST' \
  -H 'ZANALYTICS-ORGID: <org-id>' \
  -H 'Authorization: Zoho-oauthtoken <access_token>' \
  --data-urlencode 'CONFIG={"confirmRestore":true}'
Copiedusing System;
using System.Collections.Generic;
using System.Text.Json;
using ZohoAnalytics;

namespace ZohoAnalyticsTest
{
    class Program
    {
        long orgId = 55522777;
        long workspaceId = 35130000001055707;

        public void RestoreWorkspaceFromBackup(IAnalyticsClient ac)
        {
            long backupId = 35130000001056701L;
            bool confirmRestore = true;
            IWorkspaceAPI workspace = ac.GetWorkspaceInstance(orgId, workspaceId);
            JsonElement result = workspace.RestoreWorkspaceFromBackup(backupId, confirmRestore, null);
            Console.WriteLine(result);
        }

        static void Main(string[] args)
        {
            string clientId = "1000.xxxxxxx";
            string clientSecret = "xxxxxxx";
            string refreshToken = "1000.xxxxxxx.xxxxxxx";
            IAnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
            Program obj = new Program();
            obj.RestoreWorkspaceFromBackup(ac);
        }
    }
}
Copiedpackage main

import (
    "fmt"
    ZAnalytics "zoho/pkg/analyticsclient"
)

var (
    clientId = "1000.xxxxxxx"
    clientSecret = "xxxxxxx"
    refreshToken = "1000.xxxxxxx.xxxxxxx"
    orgId = "55522777"
    workspaceId = "35130000001055707"
)

func RestoreWorkspaceFromBackup(ac ZAnalytics.Client) {
    backupid := "35130000001056701"
    confirmrestore := true
    workspace := ZAnalytics.GetWorkspaceInstance(&ac, orgId, workspaceId)
    result, exception := workspace.RestoreWorkspaceFromBackup(backupid, confirmrestore, nil)
    if exception != nil {
        fmt.Println(exception.ErrorMessage)
        return
    }
    fmt.Println(result)
}

func main() {
    ac := ZAnalytics.GetAnalyticsClient(clientId, clientSecret, refreshToken)
    RestoreWorkspaceFromBackup(ac)
}
Copiedimport com.zoho.analytics.client.*;
import org.json.*;

public class Test {
    private long orgId = 55522777l;
    private long workspaceId = 35130000001055707l;

    public static void main(String args[]) {
        String clientId = "1000.xxxxxxx";
        String clientSecret = "xxxxxxx";
        String refreshToken = "1000.xxxxxxx.xxxxxxx";
        Test tObj = new Test();
        AnalyticsClient ac = new AnalyticsClient(clientId, clientSecret, refreshToken);
        try {
            tObj.restoreWorkspaceFromBackup(ac);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void restoreWorkspaceFromBackup(AnalyticsClient ac) throws Exception {
        long backupId = 35130000001056701l;
        boolean confirmRestore = true;
        WorkspaceAPI workspace = ac.getWorkspaceInstance(orgId, workspaceId);
        JSONObject result = workspace.restoreWorkspaceFromBackup(backupId, confirmRestore, null);
        System.out.println(result);
    }
}
Copied<?php
require 'AnalyticsClient.php';

class Test {
    public $ac;
    public $org_id = "55522777";
    public $workspace_id = "35130000001055707";

    function __construct() {
        $this->ac = new AnalyticsClient("1000.xxxxxxx", "xxxxxxx", "1000.xxxxxxx.xxxxxxx");
    }

    function restoreWorkspaceFromBackup() {
        $backup_id = "35130000001056701";
        $confirm_restore = true;
        $workspace = $this->ac->getWorkspaceInstance($this->org_id, $this->workspace_id);
        $response = $workspace->restoreWorkspaceFromBackup($backup_id, $confirm_restore);
        print_r($response);
    }
}

$obj = new Test();
$obj->restoreWorkspaceFromBackup();
?>
Copiedfrom AnalyticsClient import AnalyticsClient

class Config:
    CLIENTID = "1000.xxxxxxx"
    CLIENTSECRET = "xxxxxxx"
    REFRESHTOKEN = "1000.xxxxxxx.xxxxxxx"
    ORGID = "55522777"
    WORKSPACEID = "35130000001055707"

class Sample:
    ac = AnalyticsClient(Config.CLIENTID, Config.CLIENTSECRET, Config.REFRESHTOKEN)

    def restore_workspace_from_backup(self, ac):
        backup_id = "35130000001056701"
        confirm_restore = True
        workspace = ac.get_workspace_instance(Config.ORGID, Config.WORKSPACEID)
        result = workspace.restore_workspace_from_backup(backup_id, confirm_restore)
        print(result)

obj = Sample()
obj.restore_workspace_from_backup(obj.ac)
Copiedvar analyticsClient = require('./AnalyticsClient');
var ac = new analyticsClient('1000.xxxxxxx', 'xxxxxxx', '1000.xxxxxxx.xxxxxxx');
var orgId = '55522777';
var workspaceId = '35130000001055707';

var backupId = "35130000001056701";
var confirmRestore = true;
var workspace = ac.getWorkspaceInstance(orgId, workspaceId);
workspace.restoreWorkspaceFromBackup(backupId, confirmRestore).then((result) => { console.log(result); }).catch((error) => { console.log(error); });
CopiedorgId = "55522777";
workspaceId = "35130000001055707";
backupId = "35130000001056601";
headersMap = Map();
headersMap.put("ZANALYTICS-ORGID", orgId);
config = {"confirmRestore": true};
response = invokeurl
parameters = "CONFIG=" + zoho.encryption.urlEncode(config.toString());
[
  url :"https://analyticsapi.zoho.com/restapi/v2/workspaces/" + workspaceId + "/backups/" + backupId + "/restore"
  type :POST
  parameters:parameters
  headers:headersMap
  connection:"analytics_oauth_connection"
];
info response;
Copiedrequire 'zoho_analytics_client'

class Config
  ORGID = "55522777"
  WORKSPACEID = "35130000001055707"
end

class Sample
  def initialize
    @ac = AnalyticsClient.new.with_data_center("US").with_oauth({
      "clientId" => "1000.xxxxxxx",
      "clientSecret" => "xxxxxxx",
      "refreshToken" => "1000.xxxxxxx.xxxxxxx"
    }).build
  end

  def restore_workspace_from_backup
    backup_id = "35130000001056701"
    confirm_restore = true
    workspace = @ac.get_workspace_instance(Config::ORGID, Config::WORKSPACEID)
    result = workspace.restore_workspace_from_backup(backup_id, confirm_restore)
    puts result
  end
end

obj = Sample.new
obj.restore_workspace_from_backup

Download client libraries:  C# | GO | JAVA | PHP | PYTHON | NodeJS | Ruby

Sample value for CONFIG parameter:

Copied{
  "confirmRestore": true
}

Sample Response:

CopiedHTTP/1.1 200 OK
Content-Type:application/json;charset=UTF-8

{
  "status": "success",
  "summary": "Restore workspace backup",
  "data": {
    "restoreId": "466206000000320007",
    "backupMode": "STRUCTURE_AND_DATA",
    "status": "IN_PROGRESS"
  }
}