Skip to content

Instantly share code, notes, and snippets.

@berkes
Created November 24, 2010 11:58
Show Gist options
  • Save berkes/713544 to your computer and use it in GitHub Desktop.
Save berkes/713544 to your computer and use it in GitHub Desktop.
Archive certain IMAP directories with archivemail.
#! /bin/bash
# create archive directories:
archiveroot="$HOME/Archief/mail/"
dir="$archiveroot`date +%Y`/`date +%m`/`date +%d`/"
mkdir -p $dir
# set passwordfile, file should contain nothing but the password.
# You should at least make this file only readable by you.
pwfile=$HOME/Private/archivemailpw
# set location of thunderbirds local database.
globalmsg=.thunderbird/1vsl0pde.default/global-messages-db.sqlite
pattern="%@mail.example.com%"
for uri in `sqlite3 $globalmsg "SELECT folderURI FROM folderLocations WHERE folderURI LIKE \"$pattern\""`; do
archivemail \
-d 60 \
-o $dir \
-u \
--no-compress \
-P $pwfile \
# enable for testing -n -v \
$uri ;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment