From f80c5575b4da98ccd99826e7fc9e671f5657f043 Mon Sep 17 00:00:00 2001 From: ryanfkeepers Date: Wed, 15 Mar 2023 15:47:20 -0600 Subject: [PATCH] update sharepoint cli examples Updates the sharepoint cli examples to better reflect the current support and utilities. --- src/cli/backup/sharepoint.go | 35 +++++++++++++++-------------------- src/cli/restore/sharepoint.go | 22 ++++++++-------------- src/cli/utils/sharepoint.go | 22 +++++++++++++--------- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/src/cli/backup/sharepoint.go b/src/cli/backup/sharepoint.go index 44b69c389..e2d468227 100644 --- a/src/cli/backup/sharepoint.go +++ b/src/cli/backup/sharepoint.go @@ -50,7 +50,7 @@ const ( corso backup create sharepoint --web-url # Backup SharePoint for two sites: HR and Team -corso backup create sharepoint --site https://example.com/hr,https://example.com/team +corso backup create sharepoint --web-url https://example.com/hr,https://example.com/team # Backup all SharePoint data for all Sites corso backup create sharepoint --web-url '*'` @@ -59,13 +59,15 @@ corso backup create sharepoint --web-url '*'` corso backup delete sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd` sharePointServiceCommandDetailsExamples = `# Explore a site's files from backup 1234abcd-12ab-cd34-56de-1234abcd +corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd -corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd --web-url https://example.com - -# Find all site files that were created before a certain date. - +# Find all files that were created before a certain date. corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \ - --web-url https://example.com --file-created-before 2015-01-01T00:00:00 + --file-created-before 2015-01-01T00:00:00 --folder "Display Templates/Style Sheets" + +# Find all files within a specific library. +corso backup details sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \ + --library documents --folder "Display Templates/Style Sheets" ` ) @@ -104,8 +106,9 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { case listCommand: c, fs = utils.AddCommand(cmd, sharePointListCmd()) - fs.StringVar(&backupID, - "backup", "", + fs.StringVar( + &backupID, + utils.BackupFN, "", "Display a specific backup, including the items that failed or were skipped during processing.") addFailedItemsFN(c) @@ -120,7 +123,8 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { options.AddSkipReduceFlag(c) - fs.StringVar(&backupID, + fs.StringVar( + &backupID, utils.BackupFN, "", "ID of the backup to retrieve.") cobra.CheckErr(c.MarkFlagRequired(utils.BackupFN)) @@ -142,16 +146,6 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { utils.FileFN, nil, "Select backup details by file name.") - fs.StringArrayVar( - &utils.Site, - utils.SiteFN, nil, - "Select backup details by site ID; accepts '"+utils.Wildcard+"' to select all sites.") - - fs.StringSliceVar( - &utils.WebURL, - utils.WebURLFN, nil, - "Select backup data by site webURL; accepts '"+utils.Wildcard+"' to select all sites.") - fs.StringSliceVar( &pageFolders, utils.PageFolderFN, nil, @@ -191,7 +185,8 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { c.Use = c.Use + " " + sharePointServiceCommandDeleteUseSuffix c.Example = sharePointServiceCommandDeleteExamples - fs.StringVar(&backupID, + fs.StringVar( + &backupID, utils.BackupFN, "", "ID of the backup to delete. (required)") cobra.CheckErr(c.MarkFlagRequired(utils.BackupFN)) diff --git a/src/cli/restore/sharepoint.go b/src/cli/restore/sharepoint.go index 8f002711b..17e464dd5 100644 --- a/src/cli/restore/sharepoint.go +++ b/src/cli/restore/sharepoint.go @@ -45,16 +45,6 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { "ID of the backup to restore. (required)") cobra.CheckErr(c.MarkFlagRequired(utils.BackupFN)) - fs.StringSliceVar( - &utils.Site, - utils.SiteFN, nil, - "Restore data by site ID; accepts '"+utils.Wildcard+"' to select all sites.") - - fs.StringSliceVar( - &utils.WebURL, - utils.WebURLFN, nil, - "Restore data by site webURL; accepts '"+utils.Wildcard+"' to select all sites.") - // sharepoint hierarchy (path/name) flags fs.StringVar( @@ -132,13 +122,17 @@ const ( sharePointServiceCommandRestoreExamples = `# Restore file with ID 98765abcdef corso restore sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd --file 98765abcdef -# Restore a Site's file named "ServerRenderTemplate.xsl in "Display Templates/Style Sheets" from a specific backup +# Restore a file named "ServerRenderTemplate.xsl in "Display Templates/Style Sheets". corso restore sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd \ - --web-url https://example.com --file "ServerRenderTemplate.xsl" --folder "Display Templates/Style Sheets" + --file "ServerRenderTemplate.xsl" --folder "Display Templates/Style Sheets" -# Restore all files from a Site that were created before 2020 when captured in a specific backup +# Restore all files that were created before 2020. corso restore sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd - --web-url https://example.com --folder "Display Templates/Style Sheets" --file-created-before 2020-01-01T00:00:00` +--file-created-before 2020-01-01T00:00:00 --folder "Display Templates/Style Sheets" + +# Restore all files in a certain library. +corso restore sharepoint --backup 1234abcd-12ab-cd34-56de-1234abcd + --library documents --folder "Display Templates/Style Sheets" ` ) // `corso restore sharepoint [...]` diff --git a/src/cli/utils/sharepoint.go b/src/cli/utils/sharepoint.go index 83cfc0a1a..35731efdf 100644 --- a/src/cli/utils/sharepoint.go +++ b/src/cli/utils/sharepoint.go @@ -15,15 +15,19 @@ const ( ) type SharePointOpts struct { - FileNames []string // for libraries, to duplicate onedrive interface - FolderPaths []string // for libraries, to duplicate onedrive interface - Library string - ListItems []string - ListPaths []string - PageFolders []string - Pages []string - Sites []string - WebURLs []string + Library string + FileNames []string // for libraries, to duplicate onedrive interface + FolderPaths []string // for libraries, to duplicate onedrive interface + + ListItems []string + ListPaths []string + + PageFolders []string + Pages []string + + Sites []string + WebURLs []string + FileCreatedAfter string FileCreatedBefore string FileModifiedAfter string