From f615198c78d1013025086bdf3bd6abbfeb68dfd0 Mon Sep 17 00:00:00 2001 From: Hitesh Pattanayak <48874082+HiteshRepo@users.noreply.github.com> Date: Tue, 30 Jan 2024 13:41:42 +0530 Subject: [PATCH] makes backup of lists explicit and not by default (#5165) makes backup of lists explicit and not by default. **Backup whole site**: ``` corso backup create sharepoint --site https://10rqc2.sharepoint.com/sites/CorsoCI Completed Backups: ID Started at Duration Status Protected resource Data 4a324fd8-dcfc-4833-961f-316d11da34e9 2024-01-30T05:45:24Z 21.530965673s Completed https://10rqc2.sharepoint.com/sites/CorsoCI Libraries corso backup details sharepoint --backup 4a324fd8-dcfc-4833-961f-316d11da34e9 ID ItemName Library ParentPath Size Owner Created Modified 15204b287c5c wat.jpg More Documents test 6.1 kB RFinders@10rqc2.onmicrosoft.com 2023-03-24T20:33:46Z 2023-03-24T20:33:46Z 69f63c25d3f1 test-file.txt Documents Corso_Test_od_restore_and_backup_multi_30-Jan-2024_05-06-04.380107/b 387 B 2024-01-30T05:06:09Z 2024-01-30T05:06:09Z c2d55ecb218f test-file.txt Documents Corso_Test_od_restore_and_backup_multi_30-Jan-2024_05-06-04.380107/folder-a 131 B 2024-01-30T05:06:11Z 2024-01-30T05:06:12Z 5d38274759fd test-file.txt Documents Corso_Test_od_restore_and_backup_multi_30-Jan-2024_05-06-04.380107 87 B 2024-01-30T05:06:06Z 2024-01-30T05:06:07Z b5c075c00737 test-file.txt Documents Corso_Test_od_restore_and_backup_multi_30-Jan-2024_05-06-04.380107/folder-a/b/folder-a 387 B 2024-01-30T05:06:16Z 2024-01-30T05:06:17Z ... ... ``` **Backup lists explicitely**: ``` corso backup create sharepoint --site https://10rqc2.sharepoint.com/sites/CorsoCI --data lists Completed Backups: ID Started at Duration Status Protected resource Data cf480086-2094-4184-82be-26e2c5c64288 2024-01-30T05:50:35Z 23.605968852s Completed https://10rqc2.sharepoint.com/sites/CorsoCI Lists corso backup details sharepoint --backup cf480086-2094-4184-82be-26e2c5c64288 ID List Items Created Modified 85d453fd0f13 Corso_Test_Sanity_2024-01-30_05-31-05_e6be57ae-4236-44aa-b506-a5801377f937 20 2024-01-30T05:31:15Z 2024-01-30T05:31:18Z f8919f072c7c Corso_Test_Sanity_Restore_20240130_053009_Corso_Test_Sanity_2024-01-30_05-29-33_4fed1e50-f045-4ebb-8a61-8fb608ac9673 20 2024-01-30T05:30:26Z 2024-01-30T05:30:29Z 821df8ab207d Corso_Test_Sanity_Restore_20240130_053147_Corso_Test_Sanity_2024-01-30_05-29-33_b44ce328-106c-4880-8e37-e0bbb510ed4d 20 2024-01-30T05:31:58Z 2024-01-30T05:32:02Z 721f0aadf07f new-list-name 1 2024-01-19T17:44:26Z 2024-01-29T04:05:42Z ... ... ``` #### Does this PR need a docs update or release note? - [ ] :white_check_mark: Yes, it's included - [x] :clock1: Yes, but in a later PR - [ ] :no_entry: No #### Type of change - [ ] :sunflower: Feature - [ ] :bug: Bugfix - [ ] :world_map: Documentation - [ ] :robot: Supportability/Tests - [ ] :computer: CI/Deployment - [x] :broom: Tech Debt/Cleanup #### Issue(s) #4754 #### Test Plan - [x] :muscle: Manual - [x] :zap: Unit test - [x] :green_heart: E2E --- src/cli/backup/sharepoint.go | 2 ++ src/cli/utils/sharepoint.go | 4 +++- src/cli/utils/sharepoint_test.go | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cli/backup/sharepoint.go b/src/cli/backup/sharepoint.go index 1ce30eca6..25bc12707 100644 --- a/src/cli/backup/sharepoint.go +++ b/src/cli/backup/sharepoint.go @@ -73,6 +73,8 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command { flags.AddSiteFlag(c, true) flags.AddSiteIDFlag(c, true) + // [TODO](hitesh) to add lists flag to invoke backup for lists + // when explicit invoke is not required anymore flags.AddDataFlag(c, []string{flags.DataLibraries}, true) flags.AddGenericBackupFlags(c) diff --git a/src/cli/utils/sharepoint.go b/src/cli/utils/sharepoint.go index 0270441a4..f405f1f1a 100644 --- a/src/cli/utils/sharepoint.go +++ b/src/cli/utils/sharepoint.go @@ -104,7 +104,9 @@ func SharePointAllowedCategories() map[string]struct{} { func AddCategories(sel *selectors.SharePointBackup, cats []string) *selectors.SharePointBackup { if len(cats) == 0 { - sel.Include(sel.LibraryFolders(selectors.Any()), sel.Lists(selectors.Any())) + // [TODO](hitesh) to enable lists without being invoked explicitly via --data flag + // sel.Include(sel.LibraryFolders(selectors.Any()), sel.Lists(selectors.Any())) + sel.Include(sel.LibraryFolders(selectors.Any())) } for _, d := range cats { diff --git a/src/cli/utils/sharepoint_test.go b/src/cli/utils/sharepoint_test.go index 09da6ea3c..13f5a95ff 100644 --- a/src/cli/utils/sharepoint_test.go +++ b/src/cli/utils/sharepoint_test.go @@ -420,7 +420,7 @@ func (suite *SharePointUtilsSuite) TestAddSharepointCategories() { { name: "none", cats: []string{}, - expectScopeLen: 2, + expectScopeLen: 1, }, { name: "libraries",