Package: gmailsync
gmailsyncSynchronize and save a backup of your Gmail messagesRequirementspython (3.6+)pipInstallationOn all systems, installgmailsyncby usingpip:pipinstallgmailsyncUpdatingpipinstallgmailsync--upgradeUsageList Gmail labels:gmailsync-lSynchronize all channels:gmailsyncSynchronize concrete channels/groups:gmailsyncgroup1group2channelXYZCreate a new Google Cloud ProjectGmailsync uses the Google API to retrieve messages from Gmail.As it is a limited service unless your pay, gmailsync does not provide a common project, but you must create your own.The free tier is far enough for a personal or professional account. Gmailsync tries to limit the requests according to Google recommendations to no reach the quota.To create a new Google Cloud Platform project go to this link and create a new project:https://console.cloud.google.com/Then you need to enable Gmail API for that project and generate a new OAuth 2.0 key and download it. This file will be the credentials file of the application in the context of gmailsync.By default gmailsync reads the credentials from a file placed in the default gmailsync configuration directory, but you can customize this path in the configuration file.XDG User Directory supportGmailsync supports XDG User Directories. That means you can place the global configuration files in$XDG_CONFIG_HOME/gmailsync/without the need to create any particular environment variable for this application or anything else.If$XDG_CONFIG_HOMEis not set, gmailsync automatically tries to use~/.config/gmailsync. If that directory does not exist, it tries to use~/.gmailsync.ConfigurationConfiguration options for gmailsync.By default gmailsync uses the configuration file located in any of these paths (in this particular order):$XDG_CONFIG_HOME/gmailsync/config~/.config/gmailsync/config~/.gmailsync/configTo specify a different path, you can use the-coption:gmailsync-canother/config/file...The configuration file looks like this:[channel-starred]mailbox:~/mail/starredquery:label:starred[channel-notifications]mailbox:~/mail/notificationsquery:label:notificationsbox_type:mbox[channel-coworkers]mailbox:~/mail/coworkersquery:from:alice@gmail.comORfrom:bob@gmail.com[group-important]channels:starred,coworkersSo, you could execute:gmailsyncto retrieve the new messages of all channels.gmailsync importantto retrieve the new messages of the channels "starred" and "coworkers".gmailsync notificationsto retrieve the new messages of the channel "notifications".gmailsync important notificationsto retrieve the new messages of the channels in the group "important" and in the channel "notifications".Etc.Configuration options are grouped in sections: general, channels, groups and log.GeneralGeneral options of the application.The section name in the configuration file isgeneral.Options:OptionDescriptionMandatoryDefaultcredentialsPath to the credentials file of your Google Cloud Platform project.No$XDG_CONFIG_HOME/gmailsync/credentials.jsonor~/.config/gmailsync/credentials.jsonor~/.gmailsync/credentials.jsontokenPath where the token file will be stored. This file contains the token for your associated Gmail account.No$XDG_CONFIG_HOME/gmailsync/token.pickleor~/.config/gmailsync/token.pickleor~/.gmailsync/token.picklebox_typeDefault box type for all channels.NomailboxGmailsync supports the following mailbox types:maildirmboxmhbabylmmdfChannelsConfiguration of the channel.The section names (one per channel) must follow this pattern:channel-{channnel_name}, where{channel_name}must be the name of the channel.Options:OptionDescriptionMandatoryDefaultmailboxPath to the directory where to store the messages.YesqueryOptional query used to retrieve the messages. Supports the same query format as the Gmail search box.No!in:chatbox_typeOptional mailbox type. If it is not defined, the default one defined ingeneralwill be used.NoGroupsConfiguration of the group.The section names (one per group) must follow this pattern:group-{group_name}, where{group}must be the name of the group.OptionsOptionDescriptionMandatoryDefaultchannelsList of channel names separated by comma.YesLogConfiguration of the logger.The section name in the configuration file islog.Options:OptionDescriptionMandatoryDefaultfilePath to the file where the logs messages will be stored.Nofile_max_bytesMax bytes to store in the file before rotate it.No104857600 (100 MB)file_backup_countMax files to keep before to remove the oldest one.No50formatLog format for console and file logger.No%(asctime)s %(levelname)s [%(name)s] %(message)sFull example[general]credentials:/etc/gmailsync/credentials.jsontoken:/etc/gmailsync/token.picklebox_type:mbox[channel-starred]mailbox:~/mail/starredquery:label:starred[channel-notifications]mailbox:~/mail/notificationsquery:label:notificationsbox_type:maildir[channel-coworkers]mailbox:~/mail/coworkersquery:from:alice@gmail.comORfrom:bob@gmail.com[group-important]channels:starred,coworkers[log]file:/var/log/gmailsync.log