2014-05-30 03:56:21 +02:00
|
|
|
@REM
|
2018-05-07 16:04:23 +02:00
|
|
|
@REM $Id: sync_loop_windows.bat,v 1.17 2018/03/22 12:46:58 gilles Exp gilles $
|
2014-05-30 03:56:21 +02:00
|
|
|
@REM
|
|
|
|
@REM imapsync massive sync example batch for Windows users
|
2015-05-28 19:04:57 +02:00
|
|
|
@REM lines beginning with @REM are just comments
|
2014-05-30 03:56:21 +02:00
|
|
|
@REM
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM See also http://imapsync.lamiral.info/FAQ.d/FAQ.Massive.txt
|
2015-05-28 19:04:57 +02:00
|
|
|
@REM
|
|
|
|
@REM You should get familiar with a simple and single imapsync transfer before
|
|
|
|
@REM playing with this loop batch file. See and play with imapsync_example.bat
|
2014-11-19 23:08:41 +01:00
|
|
|
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM ==== How it works ====
|
|
|
|
@REM
|
|
|
|
@REM The files
|
|
|
|
@REM * sync_loop_windows.bat
|
|
|
|
@REM * imapsync or imapsync.exe and
|
|
|
|
@REM * file.txt
|
|
|
|
@REM are supposed to be in the same directory.
|
|
|
|
|
|
|
|
|
|
|
|
@REM ==== Credentials file ====
|
|
|
|
@REM
|
|
|
|
@REM Credentials data are supposed to be in the file named "file.txt" in the following format:
|
|
|
|
@REM host001_1;user001_1;password001_1;host001_2;user001_2;password001_2;
|
2014-05-30 03:56:21 +02:00
|
|
|
@REM ...
|
|
|
|
@REM Separator is character semi-colon ; it can be replaced with any character by changing
|
|
|
|
@REM the part "delims=;" in the FOR loop below.
|
|
|
|
@REM
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM Each data line contains 6 columns, columns are parameter values for
|
|
|
|
@REM --host1 --user1 --password1 --host2 --user2 --password2
|
|
|
|
@REM and a fake parameter to avoid CRLF part going into the 6th parameter password2.
|
2014-05-30 03:56:21 +02:00
|
|
|
@REM The credentials filename "file.txt" used for the loop can be renamed
|
|
|
|
@REM by changing "SET csvfile=file.txt" below.
|
|
|
|
|
|
|
|
@REM ==== Log files ====
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM
|
2015-05-28 19:04:57 +02:00
|
|
|
@REM Log files are in the LOG_imapsync sub-folder
|
2014-05-30 03:56:21 +02:00
|
|
|
|
|
|
|
@REM ==== Parallel executions ====
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM
|
2014-05-30 03:56:21 +02:00
|
|
|
@REM If you want to do parallel runs of imapsync then this current script is a good start.
|
|
|
|
@REM Just copy it several times and replace, on each copy, the csvfile variable value.
|
|
|
|
@REM Instead of SET csvfile=file.txt write for example
|
|
|
|
@REM SET csvfile=file01.txt in the first copy
|
|
|
|
@REM then also
|
|
|
|
@REM SET csvfile=file02.txt in the second copy etc.
|
|
|
|
@REM Of course you also have to split data contained in file.txt
|
|
|
|
@REM into file01.txt file02.txt etc.
|
|
|
|
@REM After that, just double-clic on each batch file to launch each process
|
2014-11-19 23:08:41 +01:00
|
|
|
@REM
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM Be aware that imapsync can be a cpu/memory cruncher on the remote imap servers,
|
2014-11-19 23:08:41 +01:00
|
|
|
@REM especially in parallel runs. The best practice rule to answer the question
|
|
|
|
@REM "how many processes in parallel can we run?" is:
|
|
|
|
@REM 1) Measure the total transfer rate by adding each one printed in each run.
|
|
|
|
@REM 2) Launch new parallel runs as long as the total transfer rate increase.
|
|
|
|
@REM 3) When the total transfer rate starts to diminish, stop new launches.
|
|
|
|
@REM Note N as the number of parallel runs you got until then.
|
|
|
|
@REM 4) Only keep N-2 parallel runs for the future.
|
2014-05-30 03:56:21 +02:00
|
|
|
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM For Parallel executions, there is also a PowerShell script written by
|
2015-05-28 19:04:57 +02:00
|
|
|
@REM CARTER Alex explained and located on the imapsync archive list:
|
|
|
|
@REM http://www.linux-france.org/prj/imapsync_list/msg02137.html
|
|
|
|
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM ==== The real stuff is below ====
|
2014-05-30 03:56:21 +02:00
|
|
|
|
|
|
|
@REM @echo off
|
2012-12-29 01:43:39 +01:00
|
|
|
|
2015-12-03 18:16:32 +01:00
|
|
|
@REM First let's go in the directory this batch is
|
|
|
|
CD /D %~dp0
|
|
|
|
|
2018-05-07 16:04:23 +02:00
|
|
|
@REM Let's get arguments of this batch, they will be added to imapsync arguments, if any.
|
|
|
|
@REM Do not touch this part to add arguments to imapsync, do that in the FOR loop below
|
2015-12-03 18:16:32 +01:00
|
|
|
@SET arguments= & @SET command=%~0
|
|
|
|
@IF %1. EQU . GOTO args_end
|
|
|
|
:args_loop
|
|
|
|
@SET arguments=%arguments% %1 & @SHIFT
|
|
|
|
@IF %1. NEQ . GOTO args_loop
|
|
|
|
@ECHO Command and arguments: %command% %arguments%
|
|
|
|
:args_end
|
|
|
|
|
|
|
|
@REM Now the loop on the csv file.
|
2013-05-21 00:04:57 +02:00
|
|
|
SET csvfile=file.txt
|
|
|
|
|
2018-05-07 16:04:23 +02:00
|
|
|
@FOR /F "tokens=1,2,3,4,5,6,7 delims=; eol=#" %%G IN (%csvfile%) DO (
|
|
|
|
@REM Blank lines are usually ignored. Dumping the tokens in [] in case debugging is needed
|
|
|
|
@ECHO GOT from %csvfile% (values are inside brackets) [%%G] [%%H] [%%I] [%%J] [%%K] [%%L] [%%M]
|
|
|
|
@REM You can add extra arguments to imapsync after the variable named %arguments%
|
2015-12-03 18:16:32 +01:00
|
|
|
@ECHO ==== Starting imapsync from --host1 %%G --user1 %%H to --host2 %%J --user2 %%K ====
|
2017-09-23 23:54:48 +02:00
|
|
|
@imapsync ^
|
2018-05-07 16:04:23 +02:00
|
|
|
--host1 %%G --user1 %%H --password1 %%I ^
|
|
|
|
--host2 %%J --user2 %%K --password2 %%L %%M %arguments%
|
2015-12-03 18:16:32 +01:00
|
|
|
@ECHO ==== Ended imapsync from --host1 %%G --user1 %%H to --host2 %%J --user2 %%K ====
|
2014-05-30 03:56:21 +02:00
|
|
|
@ECHO.
|
|
|
|
)
|
2012-12-29 01:43:39 +01:00
|
|
|
|
2014-05-30 03:56:21 +02:00
|
|
|
@ECHO Loop finished!
|
|
|
|
@ECHO Log files are in LOG_imapsync directory
|
|
|
|
@PAUSE
|