Sample Code:
global class AccountUndeleteBatchApex implements Database.Batchable<sObject>{ global Database.queryLocator start(Database.BatchableContext bc){ String query = 'SELECT Id, Name FROM Account WHERE IsDeleted = True ALL ROWS'; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext bc, List<Account> scope){ List<Account> accList = new List<Account>(); for(Account s:scope){ //Write your logic accList.add(s); } Undelete accList; } global void finish(Database.BatchableContext bc){ } }