Improve the options implied by --gmail1 and --gmail2

--gmail1 without --gmail2 implies the new --skipallmailduplicates option.
--gmail2 wihtout --gmail1 doesn't imply --skipcrossduplicates
Both together imply syncing labels and process only [Gmail]/All Mail
This commit is contained in:
Mike Alexander 2020-11-27 23:45:25 -05:00
parent 5a2605d632
commit 676e8af027
2 changed files with 31 additions and 13 deletions

View file

@ -170,8 +170,7 @@ imapsync \
--maxsleep 2 \ --maxsleep 2 \
--synclabels \ --synclabels \
--resynclabels \ --resynclabels \
--exclude "\[Gmail\]$" \ --folder "[Gmail]/All Mail"
--folderlast "[Gmail]/All Mail"
With --gmail1 --gmail2 you can override the parameters With --gmail1 --gmail2 you can override the parameters
that are activated by them, for example: that are activated by them, for example:
@ -215,8 +214,12 @@ incomprehensible alphabets, a headache for imap sysadmins.
See a listing here: See a listing here:
http://stackoverflow.com/questions/2185391/localized-gmail-imap-folders/2185548#2185548 http://stackoverflow.com/questions/2185391/localized-gmail-imap-folders/2185548#2185548
--exclude "\[Gmail\]$" is just there to avoid a warning error --synclabels and --resynclabels causes messages to all have the
when selecting this not used folder. same labels on host2 as they have on host1
--folder "[Gmail]/All Mail" makes imapsync process only the All Mail
folder. Since it is syncing all labels this will sync all messages with
their correct labels.
Be aware that --gmail1 --gmail2 is a special case, it's not what Be aware that --gmail1 --gmail2 is a special case, it's not what
--gmail1 does plus what --gmail2 does when they are not invoked --gmail1 does plus what --gmail2 does when they are not invoked
@ -252,7 +255,9 @@ imapsync --host1 mail.oldhost.com \
--expunge1 \ --expunge1 \
--addheader \ --addheader \
--maxsleep 2 \ --maxsleep 2 \
--maxsize 35_651_584 \
--exclude "\[Gmail\]$" \ --exclude "\[Gmail\]$" \
--useheader='Message-Id'
--regextrans2 's,\[Gmail\].,,' \ --regextrans2 's,\[Gmail\].,,' \
--regextrans2 's,^ +| +$,,g' --regextrans2 's,^ +| +$,,g'
--regextrans2 's,/ +| +/,/,g' --regextrans2 's,/ +| +/,/,g'
@ -287,8 +292,8 @@ be 500_000_000, not 1_000_000_000, but 1GB is usually ok.
--maxsleep 2 is to avoid sleeping more than 2 seconds when --maxsleep 2 is to avoid sleeping more than 2 seconds when
the --maxbytespersecond value implies a long sleep between 2 copies. the --maxbytespersecond value implies a long sleep between 2 copies.
--maxsize 25_000_000 is mandatory since Gmail limits messages size --maxsize 35_651_584 is mandatory since Gmail limits messages size
up to 25 MB. This value increases over time, it was 10 MB some up to 35 MB. This value increases over time, it was 10 MB some
years ago so you can try higher values. The Gmail page about years ago so you can try higher values. The Gmail page about
this limit is https://support.google.com/mail/answer/6584 this limit is https://support.google.com/mail/answer/6584
@ -301,7 +306,6 @@ marked \Deleted but deletes or moves them just after.
Option --expunge1 really removes messages marked \Deleted on host1 Option --expunge1 really removes messages marked \Deleted on host1
so they are not synced at all. so they are not synced at all.
The --addheader option is there because "Sent" folder messages The --addheader option is there because "Sent" folder messages
sometimes lack the "Message-Id:" and "Received:" headers needed sometimes lack the "Message-Id:" and "Received:" headers needed
by imapsync to identify messages (only when --useuid is not used). by imapsync to identify messages (only when --useuid is not used).
@ -313,6 +317,9 @@ the imap UID of the message on the host1 folder, like
"Could not examine: 43 NO [NONEXISTENT] Unknown Mailbox: [Gmail] "Could not examine: 43 NO [NONEXISTENT] Unknown Mailbox: [Gmail]
(now in authenticated state) (Failure)". (now in authenticated state) (Failure)".
--useheader='Message-Id' causes imapsync to use the Message-Id header
to uniquely identify a message for dtecting duplicates.
--regextrans2 "s/[ ]+/_/g" is there to convert blank characters not --regextrans2 "s/[ ]+/_/g" is there to convert blank characters not
accepted by gmail to character _ underscore. In fact only leading accepted by gmail to character _ underscore. In fact only leading
and trailing blank characters are problems with gmail, and and trailing blank characters are problems with gmail, and
@ -332,6 +339,9 @@ not accepted by gmail, character ^ to character _ underscore.
--regextrans2 "s/['\"\\\\]/_/g" is optional. It converts --regextrans2 "s/['\"\\\\]/_/g" is optional. It converts
characters ' or " or \ to character _ underscore. characters ' or " or \ to character _ underscore.
--folderlast "[Gmail]/All Mail" makes imapsync leave the All Aail
folder until the last.
You can select folders exported to imap within the gmail preferences. You can select folders exported to imap within the gmail preferences.
Select or unselect some "System labels", depending on your needs. Select or unselect some "System labels", depending on your needs.
@ -363,7 +373,7 @@ imapsync \
--maxbytesafter 2_500_000_000 --maxbytesafter 2_500_000_000
--automap \ --automap \
--maxsleep 2 \ --maxsleep 2 \
--skipcrossduplicates \ --noskipcrossduplicates --skipallmailduplicates \
--useheader="X-Gmail-Received" \ --useheader="X-Gmail-Received" \
--useheader "Message-Id" \ --useheader "Message-Id" \
--regextrans2 "s,\[Gmail\].,," \ --regextrans2 "s,\[Gmail\].,," \
@ -421,6 +431,11 @@ label CanWait and only it.
--skipcrossduplicates, will only put in "[Gmail]/All Mail" --skipcrossduplicates, will only put in "[Gmail]/All Mail"
the messages that are not labeled at all. the messages that are not labeled at all.
--skipallmailduplicates is similar to --skipcrossduplicates but it only
skips messages in the [GMAIL]/All Mail folder. Messages with two or
more other labels are copied to all the corresponding IMAP folders on
the destination. --skipallmailduplicates is the default with --gmail1.
https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt
======================================================================= =======================================================================

View file

@ -15486,11 +15486,11 @@ sub gmail12
$mysync->{maxbytesafter} ||= 1_000_000_000 ; $mysync->{maxbytesafter} ||= 1_000_000_000 ;
$mysync->{automap} = ( defined $mysync->{automap} ) ? $mysync->{automap} : 1 ; $mysync->{automap} = ( defined $mysync->{automap} ) ? $mysync->{automap} : 1 ;
$mysync->{maxsleep} = ( defined $mysync->{maxsleep} ) ? $mysync->{maxsleep} : $MAX_SLEEP ; ; $mysync->{maxsleep} = ( defined $mysync->{maxsleep} ) ? $mysync->{maxsleep} : $MAX_SLEEP ; ;
$skipcrossduplicates = ( defined $skipcrossduplicates ) ? $skipcrossduplicates : 0 ;
$mysync->{ synclabels } = ( defined $mysync->{ synclabels } ) ? $mysync->{ synclabels } : 1 ; $mysync->{ synclabels } = ( defined $mysync->{ synclabels } ) ? $mysync->{ synclabels } : 1 ;
$mysync->{ resynclabels } = ( defined $mysync->{ resynclabels } ) ? $mysync->{ resynclabels } : 1 ; $mysync->{ resynclabels } = ( defined $mysync->{ resynclabels } ) ? $mysync->{ resynclabels } : 1 ;
push @exclude, '\[Gmail\]$' ; # If we resync labels then we only need to do the All Mail folder since all messages
push @folderlast, '[Gmail]/All Mail' ; # will be in it and all will get their correct labels in the destination.
push @{ $mysync->{ folder } }, '[Gmail]/All Mail' ;
return ; return ;
} }
@ -15505,7 +15505,11 @@ sub gmail1
$mysync->{maxbytesafter} ||= 2_500_000_000 ; $mysync->{maxbytesafter} ||= 2_500_000_000 ;
$mysync->{automap} = ( defined $mysync->{automap} ) ? $mysync->{automap} : 1 ; $mysync->{automap} = ( defined $mysync->{automap} ) ? $mysync->{automap} : 1 ;
$mysync->{maxsleep} = ( defined $mysync->{maxsleep} ) ? $mysync->{maxsleep} : $MAX_SLEEP ; ; $mysync->{maxsleep} = ( defined $mysync->{maxsleep} ) ? $mysync->{maxsleep} : $MAX_SLEEP ; ;
$skipcrossduplicates = ( defined $skipcrossduplicates ) ? $skipcrossduplicates : 1 ; if ( not defined $skipcrossduplicates
and not defined $skipallmailduplicates ) {
$skipcrossduplicates = 0;
$skipallmailduplicates = 1;
}
push @useheader, 'X-Gmail-Received', 'Message-Id' ; push @useheader, 'X-Gmail-Received', 'Message-Id' ;
push @{ $mysync->{ regextrans2 } }, 's,\[Gmail\].,,' ; push @{ $mysync->{ regextrans2 } }, 's,\[Gmail\].,,' ;
@ -15523,7 +15527,6 @@ sub gmail2
$mysync->{maxbytesafter} ||= 1_000_000_000 ; # In fact it is documented as half: 500_000_000 $mysync->{maxbytesafter} ||= 1_000_000_000 ; # In fact it is documented as half: 500_000_000
$mysync->{automap} = ( defined $mysync->{automap} ) ? $mysync->{automap} : 1 ; $mysync->{automap} = ( defined $mysync->{automap} ) ? $mysync->{automap} : 1 ;
#$skipcrossduplicates = ( defined $skipcrossduplicates ) ? $skipcrossduplicates : 1 ;
$mysync->{ expunge1 } = ( defined $mysync->{ expunge1 } ) ? $mysync->{ expunge1 } : 1 ; $mysync->{ expunge1 } = ( defined $mysync->{ expunge1 } ) ? $mysync->{ expunge1 } : 1 ;
$mysync->{addheader} = ( defined $mysync->{addheader} ) ? $mysync->{addheader} : 1 ; $mysync->{addheader} = ( defined $mysync->{addheader} ) ? $mysync->{addheader} : 1 ;
$mysync->{maxsleep} = ( defined $mysync->{maxsleep} ) ? $mysync->{maxsleep} : $MAX_SLEEP ; ; $mysync->{maxsleep} = ( defined $mysync->{maxsleep} ) ? $mysync->{maxsleep} : $MAX_SLEEP ; ;