mirror of
https://github.com/imapsync/imapsync.git
synced 2025-06-09 22:24:33 +02:00
2.140
This commit is contained in:
parent
4ce248c075
commit
f26b2573c3
370 changed files with 14441 additions and 136699 deletions
|
@ -1,16 +1,21 @@
|
|||
# Example file.txt for imapsync massive migration.
|
||||
#
|
||||
# $Id: file.txt,v 1.14 2018/02/11 13:42:58 gilles Exp gilles $
|
||||
# $Id: file.txt,v 1.15 2020/03/10 19:49:52 gilles Exp gilles $
|
||||
#
|
||||
# Each line contains 6 columns, columns are parameters for
|
||||
# Each line contains at least 6 columns, columns are parameters for
|
||||
# --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.
|
||||
#
|
||||
# Windows: see the script examples/sync_loop_windows.bat
|
||||
# Unix: see the script examples/sync_loop_unix.sh
|
||||
# Extra columns can be used to pass extra parameters but the script reading
|
||||
# this file have to read them into some variables.
|
||||
#
|
||||
# Lines starting with a # are comments and ignored
|
||||
# Last, 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
|
||||
|
||||
|
||||
|
@ -24,3 +29,7 @@ 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;
|
||||
|
||||
# The reverse
|
||||
test2.lamiral.info;test2;secret2;test1.lamiral.info;test1;secret1;
|
||||
|
||||
|
|
|
@ -1,50 +1,65 @@
|
|||
@REM $Id: imapsync_example.bat,v 1.10 2016/04/07 23:14:09 gilles Exp gilles $
|
||||
@REM $Id: imapsync_example.bat,v 1.11 2020/01/07 00:45:36 gilles Exp gilles $
|
||||
|
||||
@REM imapsync example batch for Windows users
|
||||
@REM lines beginning with @REM are just comments
|
||||
@REM Please read them, they are written for you, human folk.
|
||||
|
||||
@REM See http://imapsync.lamiral.info/#doc
|
||||
@REM for more details on how to use imapsync.
|
||||
@REM Read also https://imapsync.lamiral.info/README_Windows.txt
|
||||
@REM for more details on how to use imapsync on Windows.
|
||||
|
||||
@REM Now let us enter the real work to fit your needs
|
||||
@REM Replace below the 6 parameters
|
||||
@REM "test1.lamiral.info" "test1" "secret1" "test2.lamiral.info" "test2" "secret2"
|
||||
@REM with your own values
|
||||
@REM Double quotes are necessary if a value contain one or more blanks.
|
||||
|
||||
@REM value "test1.lamiral.info" for --host1 is the IMAP source server hostname or IP address
|
||||
@REM value "test1" for --user1 is the IMAP source user login
|
||||
@REM value "secret1" for --password1 is the IMAP source user password
|
||||
@REM value "test1.lamiral.info" for --host1 is the IMAP source server hostname or IP address
|
||||
@REM value "test1" for --user1 is the IMAP source user login
|
||||
@REM value "secret1" for --password1 is the IMAP source user password
|
||||
|
||||
@REM value "test2.lamiral.info" for --host2 is the IMAP destination server hostname or IP address
|
||||
@REM value "test2" for --user2 is the IMAP destination user login
|
||||
@REM value "secret2" for --password2 is the IMAP destination user password
|
||||
@REM value "test2" for --user2 is the IMAP destination user login
|
||||
@REM value "secret2" for --password2 is the IMAP destination user password
|
||||
|
||||
@REM Character ^ at the end of the first line is essential and means
|
||||
@REM "this command continues on the next line". You can add other lines
|
||||
@REM but don't forget ^ character lasting each line, except the last one.
|
||||
|
||||
@REM That is not all, keep on reading!
|
||||
|
||||
@REM Three other options are in this example because they are good to start with
|
||||
@REM
|
||||
@REM --dry makes imapsync doing nothing, just print what would be done without --dry.
|
||||
@REM
|
||||
@REM --justfolders does only things about folders (ignore messages). It is good
|
||||
@REM to verify the folder mapping is good for you.
|
||||
@REM so if you leave --dry then imapsync will not sync your data.
|
||||
|
||||
@REM --justfolders does only folders creations, it ignores messages.
|
||||
@REM This option is good to verify the folder mapping is good for you
|
||||
@REM without starting to copy/pollute folders with messages.
|
||||
@REM
|
||||
@REM --automap guesses folders mapping, for folders like
|
||||
@REM --automap guesses folders mapping, it wors for folders like
|
||||
@REM "Sent", "Junk", "Drafts", "All", "Archive", "Flagged".
|
||||
@REM
|
||||
@REM I suggest to start with --automap --justfolders --dry.
|
||||
@REM If the folder mapping is not good then add some --f1f2 folder1=folder2
|
||||
@REM to fix it.
|
||||
@REM Then remove --dry and have a run to create folders on host2.
|
||||
@REM I suggest/impose to start with --automap --justfolders --dry.
|
||||
@REM If the folder mapping you see in the output is not good then add
|
||||
@REM some options --f1f2 "folder1=folder2"
|
||||
@REM in oder to fix it.
|
||||
|
||||
@REM Once you are happy with the folder names on the destination,
|
||||
@REM remove --dry and have a run to create folders on host2.
|
||||
|
||||
@REM If everything goes well so far then remove --justfolders to
|
||||
@REM start syncing messages.
|
||||
|
||||
.\imapsync.exe --host1 test1.lamiral.info --user1 test1 --password1 "secret1" ^
|
||||
--host2 test2.lamiral.info --user2 test2 --password2 "secret2" ^
|
||||
@REM In case you are impatient, just remove --justfolders --dry
|
||||
@REM in the firt place and go. Imapsync is not that bad by default anyway!
|
||||
|
||||
|
||||
.\imapsync.exe --host1 "test1.lamiral.info" --user1 "test1" --password1 "secret1" ^
|
||||
--host2 "test2.lamiral.info" --user2 "test2" --password2 "secret2" ^
|
||||
--automap --justfolders --dry
|
||||
|
||||
|
||||
@ECHO The sync is over.
|
||||
@ECHO Hit any key to close this window
|
||||
@ECHO the following word "to continue" means in fact "to close this window"
|
||||
@PAUSE
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $Id: sync_loop_unix.sh,v 1.8 2018/02/12 21:53:40 gilles Exp gilles $
|
||||
# $Id: sync_loop_unix.sh,v 1.10 2020/12/11 18:09:11 gilles Exp gilles $
|
||||
|
||||
# Example for imapsync massive migration on Unix systems.
|
||||
# See also http://imapsync.lamiral.info/FAQ.d/FAQ.Massive.txt
|
||||
|
@ -26,14 +26,21 @@
|
|||
|
||||
echo Looping on account credentials found in file.txt
|
||||
echo
|
||||
|
||||
line_counter=0
|
||||
> file_failures.txt
|
||||
{ while IFS=';' read h1 u1 p1 h2 u2 p2 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 ===="
|
||||
imapsync --host1 "$h1" --user1 "$u1" --password1 "$p1" \
|
||||
if imapsync --host1 "$h1" --user1 "$u1" --password1 "$p1" \
|
||||
--host2 "$h2" --user2 "$u2" --password2 "$p2" \
|
||||
"$@"
|
||||
"$@"
|
||||
then
|
||||
echo "success sync for line $line_counter "
|
||||
else
|
||||
echo "$h1;$u1;$p1;$h2;$u2;$p2;" | tee -a file_failures.txt
|
||||
fi
|
||||
echo "==== Ended imapsync from host1 $h1 user1 $u1 to host2 $h2 user2 $u2 ===="
|
||||
echo
|
||||
done
|
||||
|
|
118
examples/sync_parallel_curl.sh
Executable file
118
examples/sync_parallel_curl.sh
Executable file
|
@ -0,0 +1,118 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $Id: sync_parallel_curl.sh,v 1.2 2020/11/16 00:40:06 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;
|
||||
# ...
|
||||
# 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
|
||||
# --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.
|
||||
#
|
||||
# Last, don't forget the last semicolon.
|
||||
#
|
||||
# You can add extra options after the last line
|
||||
# Use character backslash \ at the end of each supplementary line, except for the last one.
|
||||
|
||||
|
||||
# The credentials filename "file.txt" used for the loop can be renamed
|
||||
# by changing "file.txt" below.
|
||||
|
||||
# Now I explain what come next, the actual stuff, which is barely
|
||||
# a single long command line written on several lines for the reading
|
||||
# convenience
|
||||
|
||||
# The first word is the parallel command itself, it's a perl utility
|
||||
# written by Ole Tange, available on Linux systems, already packaged.
|
||||
# It is also called GNU Parallel. The GNU Parallel homepage is
|
||||
# https://www.gnu.org/software/parallel/
|
||||
# Parallel is very powerful, you could easily distribute the parallel stuff
|
||||
# on remote machines with it (not used here).
|
||||
|
||||
# The parallel command is then followed by its parameters.
|
||||
# parallel parameters explained:
|
||||
#
|
||||
# --max-procs jobs means parallel will parallelize up to x jobs at a time,
|
||||
# x being the number stored in the file jobs.
|
||||
# Adjust this value by monitoring your system capacity and changing it with
|
||||
# echo 7 > jobs
|
||||
#
|
||||
# --delay 1.1 means parallel will pause 1.1 seconds after starting each job.
|
||||
#
|
||||
# --colsep ';' means the separator between values is the character semi-colon ;
|
||||
#
|
||||
# --arg-file file.txt means the actual input file is named file.txt
|
||||
#
|
||||
# --line-buffer means outputs will be of whole lines instead of a big mess
|
||||
# of part of them for the different processes. One line belongs to one process.
|
||||
#
|
||||
# --tagstring "job {#} slot {%} using {1} from {3} to {6} : "
|
||||
# means that each line will begin with the
|
||||
# words "job {#} slot {%} using {1} from {3} to {6} : "
|
||||
# where:
|
||||
# {1} will be replaced by the column of the file servers.txt, aka the CGI imapsync url
|
||||
# {3} will be replaced by the second column element, aka user1
|
||||
# {6} will be replaced by the fifth column element, aka user2.
|
||||
# Hack this part as you wish
|
||||
|
||||
|
||||
# The remaining parameters is the command to be executed by the parallel
|
||||
# command, ie, the command to be run several times in parallel with
|
||||
# different parameters each time.
|
||||
|
||||
# Some explanations about this remaining parts.
|
||||
#
|
||||
# The part 'echo {1} | egrep "^#" > /dev/null ||' is just there to skip
|
||||
# commented lines in file.txt
|
||||
# It can be removed if there is no comment lines in file.txt
|
||||
|
||||
# The part $DRYRUN is a variable that can be either the echo command
|
||||
# or nothing. It is a trick to permit you to see the command and its
|
||||
# parameters without running it
|
||||
#
|
||||
|
||||
|
||||
# {2} will be replaced by the first column in file.txt
|
||||
# {3} will be replaced by the second column in file.txt
|
||||
# {4} will be replaced by the third column in file.txt
|
||||
# ...
|
||||
|
||||
|
||||
# "$@" will be replaced by the parameters of this script itself,
|
||||
# the one you are reading now. It's usefull if you want to
|
||||
# add temporarly a parameter for all runs without editing any file.
|
||||
# For example,
|
||||
# sync_parallel_curl.sh --justlogin
|
||||
# will run all imapsync with the --justlogin parameter added.
|
||||
|
||||
|
||||
|
||||
check_parallel_is_here() {
|
||||
parallel --version > /dev/null || { echo "parallel command is not installed. Install it first."; return 1; }
|
||||
}
|
||||
|
||||
# First, there is no need to go further if the parallel command is not avalable
|
||||
# one the current system.
|
||||
|
||||
check_parallel_is_here || exit 1 ;
|
||||
|
||||
echo Looping with parallel on account credentials found in file.txt
|
||||
echo
|
||||
|
||||
|
||||
DRYRUN=echo
|
||||
# Comment the next line if you want to see the imapsync command instead of running it
|
||||
# since the previous echo value will be discarded
|
||||
DRYRUN=
|
||||
|
||||
parallel --max-procs jobs --delay 1.1 --colsep ';' --link --arg-file servers.txt --arg-file file.txt --line-buffer --tagstring "job {#} slot {%} using {1} from {3} to {6} : " \
|
||||
'echo {1} | egrep "^#|^ *$" > /dev/null ||' \
|
||||
$DRYRUN "curl -k -s -d 'host1='{2}';user1='{3}';password1='{4}';host2='{5}';user2='{6}';password2='{7} {1}"
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $Id: sync_parallel_unix.sh,v 1.7 2018/12/06 10:09:03 gilles Exp gilles $
|
||||
# $Id: sync_parallel_unix.sh,v 1.9 2021/02/19 13:41:51 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:
|
||||
# https://stackoverflow.com/questions/52393850/how-to-install-gnu-parallel-on-windows-10-using-git-bash
|
||||
|
||||
|
||||
# Example for imapsync massive migration on Unix systems.
|
||||
# See also http://imapsync.lamiral.info/FAQ.d/FAQ.Massive.txt
|
||||
|
@ -12,8 +17,11 @@
|
|||
# in the while loop below.
|
||||
# # Each line contains 6 columns, columns are parameter values for
|
||||
# --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.
|
||||
#
|
||||
# Extra columns can be used to pass extra parameters but the script reading
|
||||
# this file have to read them into some variables.
|
||||
#
|
||||
# Last, don't forget the last semicolon.
|
||||
#
|
||||
# You can add extra options after the last line
|
||||
# Use character backslash \ at the end of each supplementary line, except for the last one.
|
||||
|
@ -22,32 +30,93 @@
|
|||
# The credentials filename "file.txt" used for the loop can be renamed
|
||||
# by changing "file.txt" below.
|
||||
|
||||
# The part 'echo {1} | egrep "^#" > /dev/null ||' is just there to skip commented lines in file.txt
|
||||
# It can be removed if there is no comment lines in file.txt
|
||||
# Now I explain what come next, the actual stuff, which is barely
|
||||
# a single long command line written on several lines for the reading
|
||||
# convenience
|
||||
|
||||
# The first word is the parallel command itself, it's a perl utility
|
||||
# written by Ole Tange, available on Linux systems, already packaged.
|
||||
# It is also called GNU Parallel. The GNU Parallel homepage is
|
||||
# https://www.gnu.org/software/parallel/
|
||||
# Parallel is very powerful, you could easily distribute the parallel stuff
|
||||
# on remote machines with it (not used here).
|
||||
|
||||
# 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,
|
||||
# adjust this value by monitoring your system capacity.
|
||||
#
|
||||
# --delay 1.1 means parallel will pause 1.1 seconds after starting each job.
|
||||
#
|
||||
# --colsep ';' means the separator between values is the character semi-colon ;
|
||||
#
|
||||
# --arg-file file.txt means the actual input file is named file.txt
|
||||
#
|
||||
# --line-buffer means outputs will be of whole lines instead of a big mess
|
||||
# of part of them for the different processes. One line belongs to one process.
|
||||
#
|
||||
# --tagstring "from {2} to {5} : " mean that each line will begin with the
|
||||
# words "from {2} to {5} : " where {2} will be replaced by the second column
|
||||
# and {5} will be replaced by the fifth column. Hack this part as you wish
|
||||
|
||||
|
||||
# The remaining parameters is the command to be executed by the parallel
|
||||
# command, ie, the command to be run several times in parallel with
|
||||
# different parameters each time.
|
||||
|
||||
# Some explanations about this remaining parts.
|
||||
#
|
||||
# The part 'echo {1} | egrep "^#" > /dev/null ||' is just there to skip
|
||||
# commented lines in file.txt
|
||||
# It can be removed if there is no comment lines in file.txt
|
||||
|
||||
# The part $DRYRUN is a variable that can be either the echo command
|
||||
# or nothing. It is a trick to permit you to see the command and its
|
||||
# parameters without running it
|
||||
#
|
||||
|
||||
# {1} will be replaced by the first column in file.txt
|
||||
# {2} will be replaced by the second column in file.txt
|
||||
# {3} will be replaced by the third column in file.txt
|
||||
# ...
|
||||
|
||||
|
||||
# "$@" will be replaced by the parameters of this script itself,
|
||||
# the one you are reading now. It's usefull if you want to
|
||||
# add temporarly a parameter for all runs without editing any file.
|
||||
# For example,
|
||||
# sync_parallel_unix.sh --justlogin
|
||||
# will run all imapsync with the --justlogin parameter added.
|
||||
|
||||
# --simulong 5 is just there to show that you can also add parameters
|
||||
# here and that you have read this section. --simulong 5 does nothing
|
||||
# else than printing "Are you still here ETA: xx/25 msgs left"
|
||||
# five times per second. It will show the living output of all
|
||||
# paralelized runs
|
||||
|
||||
# --delay 2 means parallel will pause 2 seconds after starting each job.
|
||||
|
||||
check_parallel_is_here() {
|
||||
parallel --version > /dev/null || { echo "parallel command is not installed. Install it first."; return 1; }
|
||||
}
|
||||
|
||||
# First, there is no need to go further if the parallel command is not avalable
|
||||
# one the current system.
|
||||
|
||||
check_parallel_is_here || exit 1 ;
|
||||
|
||||
echo Looping with parallel on account credentials found in file.txt
|
||||
echo
|
||||
|
||||
|
||||
DRYRUN=echo
|
||||
# Comment the next line if you want to see the imapsync command instead of running it
|
||||
# since the previous echo value will be discarded
|
||||
DRYRUN=
|
||||
|
||||
parallel --max-procs 7 --delay 2 --colsep ';' --arg-file file.txt --line-buffer --tagstring "from {2} to {5} : " \
|
||||
parallel --max-procs 7 --delay 1.1 --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}
|
||||
--host2 {4} --user2 {5} --password2 {6} "$@" --simulong 5
|
||||
|
||||
|
||||
|
||||
# {=7=} "$@"
|
Loading…
Add table
Add a link
Reference in a new issue