Blame | Last modification | View Log | Download | RSS feed
#! /bin/bash
# script to run imapsync on a group of e-mail accounts
# Accounts are listed in users.list (default) or any text file of your choice
# in the SAME DIRECTORY as the script
# Two optional and positional parameters
# Param 1 -- input file name overriding default users.list (filename only)
# Param 2 -- If entered (any value), will place script in test mode
# INPUT file is a line terminated, colon separated list of e-mail addresses/passwords
# source_email:source_password:target_email:target_password
# each line in the file is considered to be a new entry.
# all e-mail will be copied from source to target
# NOTE: passwords can not contain colons, dollar signs, or any characters subject to shell substitution!!!
# set these to the source and target servers. Source is where you are coping FROM
SOURCE_SERVER=amy.dailydata.net
TARGET_SERVER=localhost
# get the path of this script
MYPATH=`dirname $0`
# load the initialization file. INPUT, OUTPUT defined
source $MYPATH/imapsync.include
# If first parameter, set it to the INPUT file name
[ "$1" == "" ] || INPUT=$MYPATH/$1
# validate the input file exists
if [ ! -e $INPUT ]
then
echo $INPUT does not exist for processing, dying
exit 1
fi
# if second parameter exists, create test parameters
[ "$2" == "" ] || TESTPARAMS=" --dry --justfolders "
# show start date/time
date > $OUTPUT
# and file name processed
echo Processing $INPUT >> $OUTPUT
# loop through all entries in input file, performing
{ while IFS=':' read src u1 p1 u2 p2; do \
imapsync \
--maxsize 20971520 \
--syncinternaldates \
--maxage 1 \
$TESTPARAMS \
--host1 $src --user1 "$u1" --password1 "$p1" --authmech1 PLAIN \
--host2 $TARGET_SERVER --user2 "$u2" --password2 "$p2" --authmech2 PLAIN --sep2 . --prefix2 '' ;
done ; } < $INPUT >> $OUTPUT
# show completion date/time
date >> $OUTPUT
# other parameters of interest for imapsync (place in TESTPARAMS
# --justconnect \
# --maxsize 5242880 \
# --dry \
# --delete2 \
# --delete2 --expunge2 \
# --maxage 1 \
# --justfolders \
# --justfoldersizes \
# --maxage 1 \
Generated by GNU Enscript 1.6.5.90.