Skip to content

Instantly share code, notes, and snippets.

@jg3
Created November 8, 2021 20:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jg3/63af3045f3c8958a58713be8f6608479 to your computer and use it in GitHub Desktop.
Save jg3/63af3045f3c8958a58713be8f6608479 to your computer and use it in GitHub Desktop.
# isync / mbsync config file
# hashed lines are comments
# references:
# https://www.jonatkinson.co.uk/posts/syncing-gmail-with-mbsync/
# http://frostyx.cz/posts/synchronize-your-2fa-gmail-with-mbsync
# https://isync.sourceforge.io/mbsync.html (RTFM!)
# https://isync.sourceforge.io/ (homepage)
# About mbsync:
# Stores - define a collection of mailboxes, a folder
# Channel - connects two stores defining their synchronization
# Account - connection details for network stores
# Group - a set of channels
## ABOUT THIS FILE:
## Many .mbsyncrc example files exist, most showing how to migrate
## from Gmail to local mail. This one is different. In here we
## move a Gmail account to an existing IMAP account on another
## system (Privateemail, a NameCheap service - not an ad, but I am
## satisfied with the ease, price, and reliability). To avoid
## folder collisions, everything in here is moved to "from-gmail"
## in the destination system. The Gmail inbox folder is move to
## the inbox of the target system. Nothing is deleted on either
## side. Using a free-tier Ubuntu EC2 instance in AWS I was able
## to install isync, scratch out this file and run it to have all
## 9-ish GB of mail moved over in a few hours (overnight). *****
####################################################################
##
## FROM (this is where are the bulk of the mail is today, Gmail)
##
IMAPAccount gmail
Host imap.gmail.com
Port 993
User user@gmail.com
Pass wwwwxxxxyyyyzzzz
# frostyx.cz config hints
SSLType IMAPS
AuthMechs LOGIN
# see https://sourceforge.net/p/isync/mailman/message/35458365/
# This slows things down a bit to help us not get killed by Gmail
PipelineDepth 50
IMAPStore gmail-from
Account gmail
##
## TO (this is where we want the Gmail to show up)
##
IMAPAccount privateemail
Host mail.privateemail.com
Port 993
User user@example.com
Pass PkPkPkPkPkPkPkPk!!
SSLType IMAPS
AuthMechs LOGIN
IMAPStore privateemail-to
Account privateemail
##
## HOW (this defines details of how to make from and to above work)
##
Channel from-and-to
Master :gmail-from:
Slave :privateemail-to:from-gmail/
CopyArrivalDate yes
Create slave
# enable the next line AFTER everything is verified working to delete from source
#Expunge Both
# Note that INBOX is not matched by wildcards, unless it lives under Path. --mbsync(1)
Patterns * !"[Gmail]/All Mail" !"[Gmail]/Important" !"[Gmail]/Starred" !"[Gmail]/Bin"
# Gotta have this or will get "does not support in-box sync state" errors
SyncState ~/.mbsync/imap-transfer
# To sync only stuff in the Gmail inbox
# mbsync --verbose --pull --create inbox-only
Channel inbox-only
Master :gmail-from:
Slave :privateemail-to:
CopyArrivalDate yes
Create slave
Patterns "INBOX"
SyncState ~/.mbsync/imap-transfer-inbox
# To sync all channels run
# mbsync --verbose --pull --create --all
## EOF ########################################## jg3 20211107 #####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment