I have tried to understad how database restore works in SQL Server. I have read from BOL about different phases within the restore operation but did not understand much. Can you please clarify what these different phases do?
To understand the phases you'll need to have a basic understanding of the recovery models and how they work.
data copy: restore the full and then differential backups you have of the databases.
redo: this rolls forward your logs effectively redoing the database changes that were lost prior to the point of failure. This is optional and won't happen in the simple recovery model.
undo: this looks at the previous restored logs and rolls back any transactions that were added to the logs but not committed to the database.
Those are the basics but obviously if you're not familiar with the recovery models they probably won't make much sense. A better answer could be provided if we had an idea of what you're trying to do.
Analysis pass through is done to build a dirty page table and an active transaction table from the last checkpoint. Redo gets locks for oldest open trxn as prep for reapplying changes from the open trxn. Undo rolls back uncommitted trxns.