papaschtroumpf Posted September 19, 2005 Report Share Posted September 19, 2005 I just had an ISP failure that lasted several days, and just as Murphy would have it, I needed to consult some old email in my gmail account, which I couldn't do without online access. I would like to figure out a way to backup my gmail mail to my linux machine in a way that I would easily consult it offline if needed. gmail has pop3 and smtp access (free for now) so it seems to be the way to go. I'm sure I could run KMail and have it act as a pop3 client, however I don't want to have kmail running all the time, I still want online access to be my primary (and almost only) way to read my email. Ideally I would like to figure a way to run something nightly in a cron job to back things up (without deleting mails from the Gmail server), with the ability to open that backup mailbox in KMail if I need offline access. Can I do that? Quote Link to comment Share on other sites More sharing options...
SoulSe Posted September 19, 2005 Report Share Posted September 19, 2005 You certainly can. You could setup a mail server on your box and have it automatically download your mail from the gmail pop servers and spool it locally on your machine. Alternatively you could cron something like mutt to download it for you. Mutt could also store it on the local spool where you could use any client (mutt included) to read it. I would go the mutt route, purely because I've never worked with a mail server before. Quote Link to comment Share on other sites More sharing options...
papaschtroumpf Posted September 20, 2005 Author Report Share Posted September 20, 2005 Thanks. I guess I need to do some research, I'm not sure what the local "spool" really means, I though mail was getting downloaded to an mbox file. Quote Link to comment Share on other sites More sharing options...
ramfree17 Posted September 20, 2005 Report Share Posted September 20, 2005 there was previously a gmailfs project which allows you to mount the gmail space as a normal filesystem. i dont know if it is still active but maybe you could use it to download all of your emails in one go. ciao! Quote Link to comment Share on other sites More sharing options...
Havin_it Posted September 20, 2005 Report Share Posted September 20, 2005 there was previously a gmailfs project which allows you to mount the gmail space as a normal filesystem. i dont know if it is still active but maybe you could use it to download all of your emails in one go. I used this on Windows a while back; good system, though it can only 'see' stuff tagged as 'GmailFS'. Not sure how it would behave with regular messages, even if you tagged 'em all. It's more aimed at backing-up your files to Gmail than your messages to your comp. The Linux version was a separate project though, so may work a little different... If you are a coder, you might find this page gives some ponters on how to go about rolling your own solution: http://johnvey.com/features/gmailapi/ Quote Link to comment Share on other sites More sharing options...
papaschtroumpf Posted October 18, 2005 Author Report Share Posted October 18, 2005 Man this is another one of those Nightmares-That-Should't-Be. I set up a special configuration for fetchmai that feeds directly into procmail and I now have a maildir structure holding my mail. I can tarball the whole thing anbd call it a backup of my gmail account. Note the question is how do I view messages offline? I can't seem to find a graphical client that meets the following criterias: - can be update automatically from acron job without running constantly - and/or can read/view the mails in the maildir structure created above. It seems that KMail will do neither. I can use mutt to see the archived mail, but this is the 21st century and I want comething a little more comfortable to use, and espeically something that will let me handles attachments. Any ideas? Quote Link to comment Share on other sites More sharing options...
papaschtroumpf Posted October 18, 2005 Author Report Share Posted October 18, 2005 OK, I decided to take the opposite approach: I set up KMail to be able to read from the gmail pop3 account (using pop3s). I also decided to use the maildir format rather than mbox. I then used this hack to control KMail from the command line (actually in a cron job) #!/bin/sh # start KMail and automatically satrt retrieving messages kmail --check # wait for messages to be retrieved, 5 minutes should be more than enough wait 300 # now use DCOP to close kmail unconditionnaly (yuk!) dcop kmail MainApplication-Interface quit # finally tar the maildir into the backup directory, keep one old copy mv -f ~/backup/gmail.tgz ~/backup/gmail_old.tgz tar czf ~/backup/mail.tgz ~/.Mail/* I'm now going to try and make kmail only show up in the icon tray rather than a full window, so that even though the cron job does this in the middle of the night, it won't be disruptive if I'm still using the computer at that time. Quote Link to comment Share on other sites More sharing options...
papaschtroumpf Posted October 20, 2005 Author Report Share Posted October 20, 2005 (edited) OK, it's not working from cron. It's working from the command line but if I run the same script from cron I get: ERROR: KUniqueApplication: Can't determine DISPLAY. Aborting. ERROR: Couldn't attach to DCOP server! I'm a little fuzzy as to how cron run stuff. I know if runs it as that user, I knwo it doesn't process you batch_profile, etc..., so paths can get screwy. Fron the error above, does cron also not have access to the running session? I'm uot of my league here Edited October 20, 2005 by papaschtroumpf Quote Link to comment Share on other sites More sharing options...
papaschtroumpf Posted October 21, 2005 Author Report Share Posted October 21, 2005 I'm having a little conversation with myself in this thread, but I figured I'd post the final solution it case it helps someone in the future. I through googling and trial and erro I managed to fix the problems above. Don't know if my solution is the "right" one but at leat it works. the only thing I have not figured out is how to force kmail to run as an icon in the system tray rather than pop a up window during the check. #!/bin/sh # start kmail and automatically check for new mail. # Since cron job is not started with a display attached, we need to specify the display kmail --check --display :0 # Wait for the mail to be downloaded. 5 minutes shouldbe more than enough # even if the scripts is not run very often, gmail has a max number of messages # that it will send in one batch (seems to be around 250) sleep 300 # exit kmail by sending it a quit command through DCOP. We must specify the user or dcop can't figure out who to talk to when run from as a cron job. dcop --user papaschtroumpf kmail MainApplication-Interface quit # Now back it all up. The grep is to prevent a message from tar saying that it's removing the leading / in the name so that the archive can be unpacked anywhere, but unfortunately it causes cron to generate an email, so we remove it sleep 5 tar czf /backup/gmail/gmail.tgz /home/papaschtroumpf/.Mail/* | grep -v " from member names" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.