public BackupInfo GetBackupInfo(string backupFileName, Server server)
        {
            var restoreDb = new Restore();
            var info = new BackupInfo();
            restoreDb.Action = RestoreActionType.Database;
            restoreDb.Devices.AddDevice(backupFileName, DeviceType.File);
            DataTable fileList = restoreDb.ReadFileList(server);

            foreach (DataRow row in fileList.Rows)
            {
                if (row.Field<string>("Type").Equals("D"))
                {
                    info.DataLogicalName = row.Field<string>("LogicalName");
                }
                else if (row.Field<string>("Type").Equals("L"))
                {
                    info.LogFiles.Add(new DatabaseFile {LogicalName = row.Field<string>("LogicalName")});
                }
            }

            return info;
        }
        private static IList<FileToRestore> MergeFilesLists(BackupInfo backupInfo, ServerInfo targetServerInfo)
        {
            var filesList = new List<FileToRestore>();

            var dataFile = new FileToRestore
                {
                    BackupLogicalName = backupInfo.DataLogicalName,
                    TargetLogicalName = targetServerInfo.DataFile.LogicalName,
                    TargetPhysicalPath = targetServerInfo.DataFile.PhysicalPath
                };

            filesList.Add(dataFile);

            int index = 0;
            foreach (DatabaseFile logfile in backupInfo.LogFiles)
            {
                string targetLogicalName = null;
                string targetPhysicalPath = null;

                if (targetServerInfo.LogsFiles.Count - 1 <= index)
                {
                    DatabaseFile targetFile = targetServerInfo.LogsFiles[index];
                    targetLogicalName = targetFile.LogicalName;
                    targetPhysicalPath = targetFile.PhysicalPath;
                }

                filesList.Add(new FileToRestore
                    {
                        BackupLogicalName = logfile.LogicalName,
                        TargetLogicalName = targetLogicalName,
                        TargetPhysicalPath = targetPhysicalPath
                    });


                index++;
            }
            return filesList;
        }