If you want to restore/undelete all deleted posts by a user, you can do this:
u=User.find_by_username('=username=');
moderator=User.find_by_username('=moderator=');
deleted_posts = Post.with_deleted.where(user_id: u.id).where("deleted_at is not null");
deleted_posts.each do |post|
PostDestroyer.new(moderator, post).recover
end
If you don’t know that you need to post the above into Rails or how to get into rails, you probably shouldn’t do this. I did do it once, and it is reasonablely safe.
How to get into rails
cd /var/discourse
./launcher enter app
rails c