2

I need to BackUp SharePoint Online Site content into local storage. I know there is no tools for it (for SharePoint Online version). I want to write my own tool that will copy all site content to a local drive (library to some archive, lists to excel file). I have about 15 SP sites which I need to backup. I know that MS stores data every 14 days on it's services, but this is not enough.

I plan to write a powershell script or programm in C#. But I can't get to site content programmatically.

How can I get content from site library or a list by PowerShell or C# in SharePoint Online?

1 Answer 1

1

For now this is what I get from another forum: For working with SPO we need SharePoint Server 2013 Client Components SDK. After that we can start to work with SPO, exsample to get context, and get all properties of site:

siteUrl = "https://yourtenantname-admin.sharepoint.com";
userName = "[email protected]";
password = "password";

using (ClientContext clientContext = new ClientContext(siteUrl))
{
    SecureString passWord = new SecureString();
    foreach (char c in password.ToCharArray()) passWord.AppendChar(c);
    clientContext.Credentials = new SharePointOnlineCredentials(userName, passWord);

    var tenant = new Tenant(clientContext);
    SPOSitePropertiesEnumerable spp = tenant.GetSiteProperties(0, true);

    clientContext.Load(spp);
    clientContext.ExecuteQuery();

    foreach (SiteProperties sp in spp)
    {
        Console.WriteLine(sp.Title);
    }
}

More samples work with SPO context.

Your Answer

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

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