So the comments and answers were useful to get me here, but this is what I settled on:
BACKUP DATABASE [OldDBName] TO DISK = 'path' WITH COPY_ONLY;
if (objectProperty(object_id('tmp_restore'), 'IsProcedure') is not null)
drop procedure dbo.tmp_restore
GO
CREATE PROCEDURE dbo.tmp_restore
@backup_path NVARCHAR(MAX)
AS
BEGIN
SET NOCOUNT ON;
RESTORE FILELISTONLY FROM DISK = @backup_path;
END
GO
CREATE TABLE #TEMP(
LogicalName VARCHAR(64), PhysicalName VARCHAR(130),
[Type] VARCHAR(1), FileGroupName VARCHAR(64),
Size DECIMAL(20, 0), MaxSize DECIMAL(25,0),
FileID bigint, CreateLSN DECIMAL(25,0),
DropLSN DECIMAL(25,0), UniqueID UNIQUEIDENTIFIER,
ReadOnlyLSN DECIMAL(25,0), ReadWriteLSN DECIMAL(25,0),
BackupSizeInBytes DECIMAL(25,0), SourceBlockSize INT,
filegroupid INT, loggroupguid UNIQUEIDENTIFIER,
differentialbaseLSN DECIMAL(25,0), differentialbaseGUID UNIQUEIDENTIFIER,
isreadonly BIT, ispresent BIT, TDEThumbpr DECIMAL)
Insert into #TEMP exec dbo.resware_tmp_restore @backup_path = 'path';
GO
DECLARE @NameData VARCHAR(64)
DECLARE @NameLog VARCHAR(64)
Set @NameData = (Select LogicalName from #TEMP t where t.Type like 'D')
Set @NameLog = (Select LogicalName from #TEMP t where t.Type like 'L')
RESTORE DATABASE [newDBName] FROM DISK = 'path'
WITH RECOVERY,
MOVE @NameData TO 'path_Data.mdf',
MOVE @NameLog TO 'path_Log.ldf'
GO
DROP TABLE #TEMP
Obviously Old/NewDBName and path have to be filled in with the proper values, but this should work.
_Dataand_logsections. Is there a way of getting these from the bak file?