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
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI 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
Save your site as template manually. Then find the template guid id.
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