1, Install SharePoint PowerShell: Install-Module SharePointPnPPowerShellOnline
2, Connect to SharePoint Online: Connect-PnPOnline –Url https://yoursite.sharepoint.com –Credentials (Get-Credential)
3, Go to the folder where you want to save the whole site collection XML and execute the command: Get-PnPProvisioningTemplate -Out “PnP-Provisioning-File.xml”