Hello,
I am trying to write a script that automates the backup of Google Apps accounts
say I have the following 5 users:
bob
sue
anthony
james
carl
I want to run getmail to an mbox file for each of them....
here is my getmail configuration:
Code:
retriever]
type = SimplePOP3SSLRetriever
server = pop.goo.com
username = bob@goo.com
password =blah123
[destination]
type = Mboxrd
path = ~/gmail-archive/gmail-backup.mbox
[options]
# print messages about each action (verbose = 2)
# Other options:
# 0 prints only warnings and errors
# 1 prints messages about retrieving and deleting messages only
verbose = 2
message_log = ~/.getmail/gmail.log
get mail runs great for a single user but I want to automate this process so I'm trying to create a script that creates a different file for each user:
Here is my thought process:
1) Search the file above (getmail.gmail) for the first '@' symbol and replace whatever comes right before it with 'bob' (or the first element in an array perhaps)
2) create new mbox file for email storage perhaps using name for convention
3) Run getmail
4) After gmailmail is finished, repeat.
I can't figure out how to do step one and two! Find an replace name@goo.com to name2@goo.com and find and replace path = ~/gmail-archive/name1.mbox with * name2.mbox
Code:
#/home/bin/bash
names= (bob sue anthony james carl)
i=count names
for (x=0, x<i, x++)
{
# Script that automates email backup
#sed -i 's/????????????/names[x] ~/.getmail/getmail.gmail
#Make new mbox file for user
#sed -i 's/????????????/names[x] ~/.getmail/getmail.gmail
getmail -r /home/pmalbrough/.getmail/getmail.gmail
}