Rclone defaults to connecting to my OneDrive /PreservationHoldLibrary folder instead of /Documents

I use rclone to connect our end-users to their OneDrive business drives. The rclone.conf files consist of just:

[OneDrive]
type = onedrive
drive_type = business

When a user wants to connect to their onedrive, they run a script that runs

rclone.exe config update OneDrive

...which opens a browser for them to type in their username and password.

Once authenticated, their H: drive mounts their OneDrive documents folder.

This has worked perfectly for everyone until today. I tried connecting by this method as a test, but instead of the documents I expected, I got a folder full of .backup files. I came to find rclone was connecting to

https://wmedu-my.sharepoint.com/personal/my_user/PreservationHoldLibrary

instead of

https://wmedu-my.sharepoint.com/personal/my_user/Documents

In running through the entire process (rclone config) as a test, I came to this prompt:

Option config_driveid.
Select drive you want to use
Choose a number from below, or type in your own string value.
Press Enter for the default (drive_id1).
1 / OneDrive (business)
\ (drive_id1, the drive_id for the /PreservationHoldLibrary subfolder)
2 / OneDrive (business)
\ (drive_id2, the drive id I actually want, for the /Documents subfolder)
config_driveid>

So, rclone config update OneDrive is selecting the wrong drive because that is listed as the default. When I go through the entire rclone config manually, I can select the correct drive (selection 2) and all is well.

This seems to be only a problem for me, now, but I am worried this may happen for other users. Is there a way to get back my /Documents as the default in this prompt and/or suppress /PreservationHoldLibrary as an option?

UPDATE: this is due to a setting the OneDrive/M365 folks changed to preserve user files from accidental deletion. So the question becomes is there a way to get rclone to automatically select the correct /Documents drive_id, or do I need to approach the other team and tell them to change back the setting?

Does Rclone document what graph call they are using? We are looking at https://graph.microsoft.com/v1.0/users/(username)/drive and https://graph.microsoft.com/v1.0/me/drive, but I don't know how Rclone does it.

Here's what I did to fix this (Powershell code):

The script below allows the user to log on via whatever web browser. From there, the .conf file gets massaged to put in the correct drive_id.

If my code can be better written, I welcome constructive criticism.

& "C:\Program Files\RClone\rclone.exe" config create OneDrive onedrive # create the rclone.conf file and allow user to sign on

# I can't get this to work when put in a variable.  I have to do the whole string in the commands below this:
# $Rclone = '"C:\Program Files\RClone\rclone.exe"'
# $ListDrives = $Rclone + ' config update OneDrive --state "*oauth-confirm,choose_type,," --result "false" --state "choose_type_done" --result "onedrive" --non-interactive'
# $AvailDrives = & $ListDrives | ConvertFrom-Json 

$AvailDrives = $(& "C:\Program Files\RClone\rclone.exe" config update OneDrive --state "*oauth-confirm,choose_type,," --result "false" --state "choose_type_done" --result "onedrive" --non-interactive) | ConvertFrom-JSON
foreach ($drive in @($AvailDrives.Option.Examples.Value)) { # Cycle through the available drives to find the one we want:
	$SelectedDrive = $(& "C:\Program Files\RClone\rclone.exe" config update OneDrive --continue --state "driveid_final" --result "$drive" --non-interactive) | convertFrom-JSON
	if ($SelectedDrive.Option.Help -notlike "*/Documents*") { # this is not what we're looking for. Run this part of setup again to get to the prompt we want:
		& "C:\Program Files\RClone\rclone.exe" config update OneDrive --state "*oauth-confirm,choose_type,," --result "false" --state "choose_type_done" --result "onedrive" --non-interactive | out-null
	} else { break; }
}
# Finally, confirm the drive we want and exit out:
& "C:\Program Files\RClone\rclone.exe" config update OneDrive --continue --state "driveid_final_end" --result "true" --non-interactive | out-null

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.