first commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.env
|
||||
sync/accounts.txt
|
||||
sync/failures.txt
|
||||
8
compose.yml
Normal file
8
compose.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
services:
|
||||
imapsync:
|
||||
image: gilleslamiral/imapsync
|
||||
restart: "no"
|
||||
# command: imapsync --host1 $HOST1 --user1 $USR1 --password1 $IMAPSYNC_PASSWORD1 --host2 $HOST2 --user2 $USR2 --password2 $IMAPSYNC_PASSWORD2 --delete2duplicates --automap
|
||||
command: bash /sync/sync_loop_unix.sh
|
||||
volumes:
|
||||
- "./sync:/sync"
|
||||
1
sync/accounts.txt.sample
Normal file
1
sync/accounts.txt.sample
Normal file
@@ -0,0 +1 @@
|
||||
host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;;
|
||||
69
sync/sync_loop_unix.sh
Normal file
69
sync/sync_loop_unix.sh
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $Id: sync_loop_unix.sh,v 1.14 2024/12/25 21:17:38 gilles Exp gilles $
|
||||
|
||||
# Example for imapsync massive migration on Unix systems.
|
||||
# See also http://imapsync.lamiral.info/FAQ.d/FAQ.Massive.txt
|
||||
#
|
||||
# Data is supposed to be in accounts.txt in the following format:
|
||||
# host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;;
|
||||
# ...
|
||||
# The separator is the character semi-colon ";"
|
||||
# this separator character can be changed to any character
|
||||
# by changing IFS=';' in the while loop below.
|
||||
#
|
||||
# Each line contains 7 columns. These columns are the 6 parameter values
|
||||
# for the imapsync command options
|
||||
# --host1 --user1 --password1 --host2 --user2 --password2
|
||||
# plus an extra column for extra parameters and a trailing fake column
|
||||
# to avoid CR LF part going in the 7th parameter extra.
|
||||
# So don't forget the last semicolon, especially on MacOS systems.
|
||||
#
|
||||
# You can also add extra options in this script after the variable "$@"
|
||||
# Those options will be applied in every imapsync run, for every line.
|
||||
|
||||
# The imapsync command below is written in two lines to avoid a long line.
|
||||
# The character backslash \ at the end of the first line is means
|
||||
# "the command continues on the next line".
|
||||
#
|
||||
# Use character backslash \ at the end of each supplementary line,
|
||||
# except for the last line.
|
||||
#
|
||||
|
||||
# You can also pass extra options via the parameters of this script since
|
||||
# they will be in "$@". Shell knowledge is your friend.
|
||||
|
||||
# The credentials filename "accounts.txt" used for the loop can be renamed
|
||||
# by changing "accounts.txt" below.
|
||||
|
||||
# The file file_failures.txt will contain the lines from accounts.txt that ended
|
||||
# up in error, for whatever reason. It's there to notice and replay easily
|
||||
# the failed imapsync runs. Is is emptied at the beginning of the loop run.
|
||||
# I let you junggle with it.
|
||||
|
||||
SRC_FILE=/sync/accounts.txt
|
||||
FAIL_FILE=/sync/failures.txt
|
||||
GLOBAL_FLAGS="--noreleasecheck"
|
||||
|
||||
echo Looping on accounts credentials found in $SRC_FILE
|
||||
echo
|
||||
line_counter=0
|
||||
# Empty the error listing
|
||||
> "$FAIL_FILE"
|
||||
{ while IFS=';' read h1 u1 p1 h2 u2 p2 extra fake
|
||||
do
|
||||
line_counter=$(expr 1 + $line_counter)
|
||||
{ echo "$h1" | tr -d '\r' | grep -E '^#|^ *$' ; } > /dev/null && continue # this skip commented lines in accounts.txt
|
||||
echo "==== Starting imapsync with --host1 $h1 --user1 $u1 --host2 $h2 --user2 $u2 $extra $GLOBAL_FLAGS $@ ===="
|
||||
echo Got those values from $SRC_FILE presented inside brackets: [$h1] [$u1] [$h2] [$u2] [$extra] [$fake]
|
||||
if eval imapsync --host1 "$h1" --user1 "$u1" --password1 "$p1" \
|
||||
--host2 "$h2" --user2 "$u2" --password2 "$p2" $extra $GLOBAL_FLAGS "$@"
|
||||
then
|
||||
echo "success sync for line $line_counter "
|
||||
else
|
||||
echo "$h1;$u1;$p1;$h2;$u2;$p2;$extra;" | tee -a $FAIL_FILE
|
||||
fi
|
||||
echo "==== Ended imapsync with --host1 $h1 --user1 $u1 --host2 $h2 --user2 $u2 $extra $GLOBAL_FLAGS $@ ===="
|
||||
echo
|
||||
done
|
||||
} < $SRC_FILE
|
||||
Reference in New Issue
Block a user