Is it possible to backup all mails from a Gmail or Yahoo mail account to my computer and then again restore them?
I use Windows XP on my machine.
You can use MsgExtract to save your email messages from any IMAP source, like Gmail or Yahoo mail, to disk as single individual files (EML, MSG or PDF).
When needed you can use MsgExtract to restore your email messages back to Gmail or to another email client like Outlook or Thunderbird.
(Disclaimer, I am the author of MsgExtract)
Yes, for Gmail, you can use this. http://www.gmail-backup.com/.
Be sure to read the documentation: http://www.gmail-backup.com/documentation