This commit is contained in:
Nick Bebout 2022-02-15 12:29:45 -06:00
parent f98c9946e5
commit 2f815205a9
72 changed files with 4567 additions and 1469 deletions

View file

@ -1,35 +1,36 @@
# Example file.txt for imapsync massive migration.
#
# $Id: file.txt,v 1.15 2020/03/10 19:49:52 gilles Exp gilles $
# $Id: file.txt,v 1.17 2022/01/09 09:49:25 gilles Exp gilles $
#
# Each line contains at least 6 columns, columns are parameters for
# Each line contains at least 6 columns
# The separator is the character semi-colon ";"
# The columns are the values for the parameters
# --host1 --user1 --password1 --host2 --user2 --password2
#
# Extra columns can be used to pass extra parameters but the script reading
# this file have to read them into some variables.
# A extra column can be used to pass some extra parameters but the script reading
# this file have to be able to get them.
#
# Last, don't forget the last semicolon.
# Don't forget the last semicolon.
#
# Windows: see the script examples/sync_loop_windows.bat
# Unix: see the script examples/sync_loop_unix.sh
# Power users: see the script examples/sync_parallel_unix.sh
# Lines starting with a # are usually comments and ignored
# Blank lines are ignored as well
# Now the data example
host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;
host002_1;user002_1;password002_1;host002_2;user002_2;password002_2;
host003_1;user003_1;password003_1;host003_2;user003_2;password003_2;
host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;;
host002_1;user002_1;password002_1;host002_2;user002_2;password002_2;--subfolder2 foo;
host003_1;user003_1;password003_1;host003_2;user003_2;password003_2;--justfolders --automap --subfolder2 foo;
# Another comment blabla
host004_1;user004_1;password004_1;host004_2;user004_2;password004_2;
host004_1;user004_1;password004_1;host004_2;user004_2;password004_2;;
# This last example is a real one, ie, truly working in the real world.
test1.lamiral.info;test1;secret1;test2.lamiral.info;test2;secret2;
test1.lamiral.info;test1;secret1;test2.lamiral.info;test2;secret2;;
# The reverse
test2.lamiral.info;test2;secret2;test1.lamiral.info;test1;secret1;
# The reverse with some extra parameters
test2.lamiral.info;test2;secret2;test1.lamiral.info;test1;secret1;--dry --subfolder2 foo;

View file

@ -1,41 +1,64 @@
#!/bin/sh
#
# $Id: sync_loop_darwin.sh,v 1.2 2018/02/12 21:54:59 gilles Exp gilles $
# $Id: sync_loop_darwin.sh,v 1.3 2022/01/10 08:03:46 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 file.txt in the following format:
# host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;
# host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;;
# ...
# Separator is character semi-colon ";" it can be changed by any character changing IFS=';'
# in the while loop below.
# # Each line contains 6 columns, columns are parameter values for
# 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
# and a trailing empty fake column to avaid CR LF part going
# in the 6th parameter password2. Don't forget the last semicolon.
# 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 add extra options after the variable "$@"
# Use character backslash \ at the end of each suplementary line, except for the last one.
# 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 "$@"
# they will be in "$@". Shell knowledge is your friend.
# The credentials filename "file.txt" used for the loop can be renamed
# by changing "file.txt" below.
# The file file_failures.txt will contain the lines from file.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.
echo Looping on account credentials found in file.txt
echo Looping on accounts credentials found in file.txt
echo
{ while IFS=';' read h1 u1 p1 h2 u2 p2 fake
line_counter=0
# Empty the error listing
> file_failures.txt
{ while IFS=';' read h1 u1 p1 h2 u2 p2 extra fake
do
{ echo "$h1" | egrep '^#|^ *$' ; } > /dev/null && continue # this skip commented lines in file.txt
echo "==== Starting imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
../imapsync_bin_Darwin --host1 "$h1" --user1 "$u1" --password1 "$p1" \
--host2 "$h2" --user2 "$u2" --password2 "$p2" \
"$@"
echo "==== Ended imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
line_counter=`expr 1 + $line_counter`
{ echo "$h1" | tr -d '\r' | egrep '^#|^ *$' ; } > /dev/null && continue # this skip commented lines in file.txt
echo "==== Starting imapsync with --host1 $h1 --user1 $u1 --host2 $h2 --user2 $u2 $extra $@ ===="
if ../imapsync_bin_Darwin --host1 "$h1" --user1 "$u1" --password1 "$p1" \
--host2 "$h2" --user2 "$u2" --password2 "$p2" $extra "$@"
then
echo "success sync for line $line_counter "
else
echo "$h1;$u1;$p1;$h2;$u2;$p2;$extra;" | tee -a file_failures.txt
fi
echo "==== Ended imapsync with --host1 $h1 --user1 $u1 --host2 $h2 --user2 $u2 $extra $@ ===="
echo
done
done
} < file.txt

View file

@ -1,48 +1,64 @@
#!/bin/sh
#
# $Id: sync_loop_unix.sh,v 1.10 2020/12/11 18:09:11 gilles Exp gilles $
# $Id: sync_loop_unix.sh,v 1.13 2022/01/09 09:53:47 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 file.txt in the following format:
# host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;
# host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;;
# ...
# Separator is character semi-colon ";" it can be changed by any character changing IFS=';'
# in the while loop below.
# # Each line contains 6 columns, columns are parameter values for
# 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
# and a trailing empty fake column to avoid CR LF part going
# in the 6th parameter password2. Don't forget the last semicolon.
# 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 add extra options after the variable "$@"
# Use character backslash \ at the end of each supplementary line, except for the last one.
# 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 "$@"
# they will be in "$@". Shell knowledge is your friend.
# The credentials filename "file.txt" used for the loop can be renamed
# by changing "file.txt" below.
# The file file_failures.txt will contain the lines from file.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.
echo Looping on account credentials found in file.txt
echo Looping on accounts credentials found in file.txt
echo
line_counter=0
# Empty the error listing
> file_failures.txt
{ while IFS=';' read h1 u1 p1 h2 u2 p2 fake
{ while IFS=';' read h1 u1 p1 h2 u2 p2 extra fake
do
line_counter=`expr 1 + $line_counter`
{ echo "$h1" | tr -d '\r' | egrep '^#|^ *$' ; } > /dev/null && continue # this skip commented lines in file.txt
echo "==== Starting imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
echo "==== Starting imapsync with --host1 $h1 --user1 $u1 --host2 $h2 --user2 $u2 $extra $@ ===="
if imapsync --host1 "$h1" --user1 "$u1" --password1 "$p1" \
--host2 "$h2" --user2 "$u2" --password2 "$p2" \
"$@"
--host2 "$h2" --user2 "$u2" --password2 "$p2" $extra "$@"
then
echo "success sync for line $line_counter "
else
echo "$h1;$u1;$p1;$h2;$u2;$p2;" | tee -a file_failures.txt
echo "$h1;$u1;$p1;$h2;$u2;$p2;$extra;" | tee -a file_failures.txt
fi
echo "==== Ended imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
echo "==== Ended imapsync with --host1 $h1 --user1 $u1 --host2 $h2 --user2 $u2 $extra $@ ===="
echo
done
done
} < file.txt

View file

@ -1,5 +1,5 @@
@REM
@REM $Id: sync_loop_windows.bat,v 1.18 2018/05/24 11:45:42 gilles Exp gilles $
@REM $Id: sync_loop_windows.bat,v 1.19 2022/01/09 09:52:44 gilles Exp gilles $
@REM
@REM imapsync massive sync example batch for Windows users
@REM lines beginning with @REM are just comments
@ -85,11 +85,11 @@ SET csvfile=file.txt
@REM Blank lines are usually ignored. Dumping the tokens in [] in case debugging is needed
@ECHO GOT those values from %csvfile% presented inside brackets: [%%G] [%%H] [%%I] [%%J] [%%K] [%%L] [%%M]
@REM You can add extra arguments to imapsync after the variable named %arguments%
@ECHO ==== Starting imapsync from --host1 %%G --user1 %%H to --host2 %%J --user2 %%K ====
@ECHO ==== Starting imapsync with --host1 %%G --user1 %%H --host2 %%J --user2 %%K %%M %arguments% ====
@imapsync ^
--host1 %%G --user1 %%H --password1 %%I ^
--host2 %%J --user2 %%K --password2 %%L %%M %arguments%
@ECHO ==== Ended imapsync from --host1 %%G --user1 %%H to --host2 %%J --user2 %%K ====
@ECHO ==== Ended imapsync with --host1 %%G --user1 %%H --host2 %%J --user2 %%K %%M %arguments% ====
@ECHO.
)

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# $Id: sync_parallel_unix.sh,v 1.9 2021/02/19 13:41:51 gilles Exp gilles $
# $Id: sync_parallel_unix.sh,v 1.11 2022/01/13 12:56:28 gilles Exp gilles $
# If you're on Windows there is a possibility to install and use parallel
# but I have never tested it. I found:
@ -44,10 +44,10 @@
# The parallel command is then followed by its parameters.
# parallel parameters explained:
#
# --max-procs 7 means parallel will parallelize up to 7 jobs at a time,
# --max-procs 3 means parallel will parallelize up to 3 jobs at a time,
# adjust this value by monitoring your system capacity.
#
# --delay 1.1 means parallel will pause 1.1 seconds after starting each job.
# --delay 1.4 means parallel will pause 1.4 seconds (1400 ms) after starting each job.
#
# --colsep ';' means the separator between values is the character semi-colon ;
#
@ -96,6 +96,8 @@
# paralelized runs
# The current script does not take into account what is in the 7th column
check_parallel_is_here() {
parallel --version > /dev/null || { echo "parallel command is not installed. Install it first."; return 1; }
}
@ -114,9 +116,14 @@ DRYRUN=echo
# since the previous echo value will be discarded
DRYRUN=
parallel --max-procs 7 --delay 1.1 --colsep ';' --arg-file file.txt --line-buffer --tagstring "from {2} to {5} : " \
parallel --max-procs 3 --delay 1.4 --colsep ';' --arg-file file.txt --line-buffer --tagstring "from {2} to {5} : " \
'echo {1} | egrep "^#|^ *$" > /dev/null ||' \
$DRYRUN imapsync --host1 {1} --user1 {2} --password1 {3} \
--host2 {4} --user2 {5} --password2 {6} "$@" --simulong 5
--host2 {4} --user2 {5} --password2 {6} "$@" --simulong 5
# A question to ask to the parallel mailing-list, Ole Tange
# does not work like I want, it passes all the 7th column as only one argument to imapsync:
# '{=7 split / /, $arg[7] =}'
# I want a list of arguments