Opening Balances for a Fiscal Year are the same as the Closing Balances of the previous year for all Balance Sheet accounts.
Opening Balances for Income Statement accounts are always zero.
Closing Balances for a fiscal year for Balance Sheet accounts are determined and brought forward as the new Opening Balances for the following year. The Profit or Loss for that prior year is determined and brought forward into the Retained Earnings account. That is, the Opening Balance for the Retained Earnings account for following year is the sum of its Closing Balance for the prior year and the net Profit or Loss in that prior year. The process starts with the earliest fiscal year and continues until all fiscal years have been processed.
This task may be run as often as required. For example, when you first start entering transactions for a new fiscal Year you typically bring forward the Opening Balances as they are at that time. Subsequently there may be additional transactions and adjustments to that prior year and you may choose to bring forward the Opening Balances again. Subsequently your auditors will prepare additional adjustments, which will be posted. So you would bring forward Opening Balances again after these last adjustments have been posted.