I have tried to write a script to save a copy of a aprx, while changing the default gdb, using the documentation I found at the link below.
aprx.defaultGeodatabase = ....
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm
However, this doesn't actually work and the resulting aprx just has the same default gdb as the original aprx I have open. Is there something I'm missing?
import arcpy, os
from arcpy import env
proj_folder = arcpy.GetParameterAsText(0)
outfolder = arcpy.GetParameterAsText(1)
aprx_name = arcpy.GetParameterAsText(2)
aprx = arcpy.mp.ArcGISProject("CURRENT")
new_gdb = proj_folder + "\\Data\\ProjComp\\ProjComp.gdb"
aprx.defaultGeodatabase = new_gdb
aprx.saveACopy(outfolder+"\\"+aprx_name)