What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Sample with spool file: .mbsyncrc, Isync, Information Lifecycle Management, dovecot, GMail, IMAP, Virtualization Station

Philip Bondi

Occasional Visitor
Hello to all:

I wanted to offer my working .mbsyncrc to the community. I also have a spool file to share.

In my opinion, 15 Gb on our Google accounts is no longer enough.
Google Photos keeps prompting to enable backup. Most people
are going to exceed this quota. In my opinion, this is
manifestation of serious "platform decay".
This is starting to affect all my immediate family members.
In my opinion, one should have methodology to move GMail
away of Google for Information Lifecycle Management.
To achieve, I have setup Debian 12 virtual machine on QNAP
running Dovecot. This setup is beyond the scope of this article.
I setup Isync to sync gmail to my Debian 12 virtual machine.
Then I wrote a script to move the gmail to local mbox.
Isync will then purge the email from Gmail.


Code:
# ****************************************************************************
#
#          $Id: .mbsyncrc 167820 2025-09-10 15:17:02Z svn_beechwood $
#        $Date: 2025-09-10 11:17:02 -0400 (Wed, 10 Sep 2025) $
#
#   Motivation: In my opinion, 15 Gb on our Google accounts is no longer enough.
#               Google Photos keeps prompting to enable backup.  Most people
#               are going to exceed this quota.  In my opinion, this is
#               manifestation of serious "platform decay".
#               This is starting to affect all my immediate family members.
#               In my opinion, one should have methodology to move GMail
#               away of Google for Information Lifecycle Management.
#               To achieve, I have setup Debian 12 virtual machine on QNAP
#               running Dovecot.  This setup is beyond the scope of this article.
#               I setup Isync to sync gmail to my Debian 12 virtual machine.
#               Then I wrote a script to move the gmail to local mbox.
#               Isync will then purge the email from Gmail.
#
#  Description: Where you have:
#               ispname that provides my-domain-on-isp and hosts their smtp server on isp-domain
#               Third-party apps & services setup for your gmail account
#               gmail-third-party-app-password is setup for isync
#               private-cloud.com setup with your own Dovecot server
#               You want to sync [email protected] to local Dovecot server
#               You want to sync [email protected] to local Dovecot server
#               Your local dovecot account is [email protected]
#               The local account for local dovecot email is local-email3
#               The local account password local dovecot email is local-password
#
#               https://mail.google.com/mail/u/0/#settings/fwdandpop
#               On GMail, configure:
#                   IMAP access:
#                   When a message is marked as deleted and expunged from the last visible IMAP folder:
#                   Move the message to the Trash
#                   or
#                   Immediately delete the message forever
#
#
#               https://wiki.archlinux.org/title/Isync
#               https://photos.google.com/quotamanagement
#               https://mail.google.com/mail/u/0/#settings/fwdandpop
#               Set up Gmail with a third-party email client
#               https://support.google.com/a/answer/9003945?hl=en&ref_topic=4456189&sjid=15956471851240922879-NC
#               Recommendations for setting up IMAP
#               https://support.google.com/a/answer/10547014?hl=en&ref_topic=4456189&sjid=15956471851240922879-NC
#               Third-party apps & services
#               https://myaccount.google.com/connections?filters=3
#
# ****************************************************************************
IMAPAccount ispname
# Address to connect to
Host smtp.isp-domain.com
User [email protected]
Pass my-domain-on-isp-password
SSLType IMAPS

IMAPAccount gmail
# Address to connect to
Host imap.gmail.com
User [email protected]
Pass gmail-third-party-app-password
#
#
SSLType IMAPS
CertificateFile /etc/ssl/certs/ca-certificates.crt

IMAPStore ispname-remote
Account ispname
MapInbox INBOX-ispname.mbx

IMAPStore gmail-remote
Account gmail
MapInbox INBOX-gmail.mbx

IMAPStore gmail-local
Path gmail/
host private-cloud.com
User local-email3
Pass local-password
SSLType IMAPS

IMAPStore ispname-local
Path ispname/
host private-cloud.com
User local-email3
Pass local-password
SSLType IMAPS

Channel gmail
Far :gmail-remote:
Near :gmail-local:
Patterns INBOX-gmail.mbx ![Gmail]* "[Gmail]/Sent Mail" "[Gmail]/Starred" "[Gmail]/All Mail"
Create Near
Expunge Both
SyncState ~/.mbsync/imap-transfer-gmail

Channel ispname
Far :ispname-remote:
Near :ispname-local:
Patterns INBOX-ispname.mbx "Sent Items"
Create Near
Expunge Both
SyncState ~/.mbsync/imap-transfer-ispname

Code:
[1789] $ mbsync -a -V
Reading configuration file /home/local-email3/.mbsyncrc
C: 0/2  B: 0/0  F: +0/0 *0/0 #0/0  N: +0/0 *0/0 #0/0
Channel gmail
Opening far side store gmail-remote...
Resolving imap.gmail.com... ok
Connecting to imap.gmail.com (142.251.179.108:993)...
Opening near side store gmail-local...
Resolving private-cloud.com... ok
Connecting to private-cloud.com (fixed-ip-address:993)...
Connection is now encrypted
Connection is now encrypted
Logging in...
Authenticating with SASL mechanism PLAIN...
Logging in...
Authenticating with SASL mechanism PLAIN...
C: 0/2  B: 0/4  F: +0/0 *0/0 #0/0  N: +0/0 *0/0 #0/0
Opening far side box INBOX...
Opening near side box INBOX-gmail.mbx...
Loading far side box...
Loading near side box...
near side: 10 messages, 0 recent
far side: 21 messages, 0 recent
Synchronizing...
C: 0/2  B: 1/4  F: +0/0 *0/0 #0/0  N: +9/9 *0/0 #0/0
Opening far side box [Gmail]/All Mail...
Opening near side box [Gmail]/All Mail...
Loading far side box...
Loading near side box...
near side: 1648 messages, 0 recent
far side: 2456 messages, 0 recent
Synchronizing...
C: 0/2  B: 2/4  F: +0/0 *0/0 #0/0  N: +221/221 *0/0 #0/0
Opening far side box [Gmail]/Sent Mail...
Opening near side box [Gmail]/Sent Mail...
Loading far side box...
Loading near side box...
near side: 0 messages, 0 recent
far side: 9 messages, 0 recent
Synchronizing...
C: 0/2  B: 3/4  F: +0/0 *0/0 #0/0  N: +230/230 *0/0 #0/0
Opening far side box [Gmail]/Starred...
Opening near side box [Gmail]/Starred...
Loading far side box...
far side: 0 messages, 0 recent
Loading near side box...
near side: 0 messages, 0 recent
Synchronizing...
C: 1/2  B: 4/4  F: +0/0 *0/0 #0/0  N: +230/230 *0/0 #0/0
Channel ispname
Opening far side store ispname-remote...
Resolving smtp.isp-domain.com... ok
Connecting to smtp.isp-domain.com (216.40.42.134:993)...
Opening near side store ispname-local...
Resolving private-cloud.com... ok
Connecting to private-cloud.com (fixed-ip-address:993)...
Connection is now encrypted
Connection is now encrypted
Logging in...
Authenticating with SASL mechanism PLAIN...
Logging in...
Authenticating with SASL mechanism PLAIN...
C: 1/2  B: 4/6  F: +0/0 *0/0 #0/0  N: +230/230 *0/0 #0/0
Opening far side box INBOX...
Opening near side box INBOX-ispname.mbx...
Loading far side box...
Loading near side box...
near side: 58 messages, 0 recent
far side: 57 messages, 0 recent
Synchronizing...
C: 1/2  B: 5/6  F: +0/0 *0/0 #0/0  N: +257/257 *30/30 #0/0
Opening far side box Sent Items...
Opening near side box Sent Items...
Loading far side box...
Loading near side box...
near side: 19 messages, 0 recent
far side: 26 messages, 0 recent
Synchronizing...
C: 2/2  B: 6/6  F: +0/0 *0/0 #0/0  N: +270/270 *36/36 #0/0
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top