0

I have created one site collection on SharePoint Online.

Now I want to make another site collection with the same content.

So can anyone explain me how to go about backup and restore of site collection in SharePoint Online (Office 365)? Using CSOM

3

1 Answer 1

2

Save your site as template manually. Then find the template guid id.

enter image description here

Now create your site using CSOM. See more here

internal void CreateSite(String targetUrl, String title, String owner, String siteTemplate)
{
    var ctx = new ClientContextWrapper(targetUrl);
    var tenant = new Tenant(ctx);

    //Create new site
    var newsite = new SiteCreationProperties()
    {
        Url = targetUrl,
        Owner = owner,
        Template = siteTemplate,
        Title = title,
        StorageMaximumLevel = 1000,
        StorageWarningLevel = 500,
        TimeZoneId = 7,
        UserCodeMaximumLevel = 7,
        UserCodeWarningLevel = 1,
    };

    var spoOperation = tenant.CreateSite(newsite);

    ctx.Load(spoOperation);
    ctx.ExecuteQuery();

    while (!spoOperation.IsComplete)
    {
        Thread.Sleep(2000);
        ctx.Load(spoOperation);
        ctx.ExecuteQuery();
        Console.WriteLine("Site creation status: " + (spoOperation.IsComplete ? "waiting" : "complete"));
    }
}

Place your custom template's guid in siteTemplate

10
  • My SharePoint Online doesn't have any option like this "ProjectSiteTemplate" in custom tab and unable to find save site as template option in office 365 Oct 8, 2015 at 5:43
  • Did you save your site as template? If so, then what is the name? It's just the name of your template what you have provided Oct 8, 2015 at 5:48
  • my sharepoint online site dosen't show option "save site as template" Oct 8, 2015 at 6:01
  • Go to the link your-site-url/_layouts/savetmpl.aspx Oct 8, 2015 at 6:04
  • Hello Atish ,my site is "Publishing Site", so i am unable to "save site as template". when i am go through this link your-site-url/_layouts/savetmpl.aspx , getting error Oct 8, 2015 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.