GithubHelp home page GithubHelp logo

jakewharton / docker-mbsync Goto Github PK

View Code? Open in Web Editor NEW
83.0 6.0 8.0 24 KB

A Docker container which runs the mbsync tool automatically to synchronize your email

Home Page: https://hub.docker.com/r/jakewharton/mbsync/

License: MIT License

Dockerfile 23.86% Shell 76.14%
docker backup email

docker-mbsync's Introduction

Docker Mailbox Sync

A Docker container which runs the mbsync tool automatically to synchronize your email.

Docker Image Version Docker Image Size

Setup

Select and create two directories:

  • The "mail" directory where email will be stored. (From now on referred to as /path/to/mail)
  • The "config" directory where your configuration file will be stored. (From now on referred to as /path/to/config)

Config

In /path/to/config, create a file mbsync.rc for configuration. See the mbsync documentation for the syntax of this file.

The examples in this README mount the destination /path/to/mail directory as /mail inside of the container. If you are going to follow that, you should use /mail as the path in your configuration.

Here is an example, minimal configuration for synchronizing everything in a mailbox:

IMAPAccount example
Host imap.example.com
User [email protected]
Pass abc123
AuthMechs LOGIN
SSLType IMAPS
PipelineDepth 50

IMAPStore example-remote
Account example

MaildirStore example-local
Path /mail/
Inbox /mail/Inbox
SubFolders Verbatim

Channel example
Master :example-remote:
Slave :example-local:
Patterns *
Create Slave
Expunge Slave
SyncState *
Sync Pull

Initial Sync

The first time this container runs, it will download all of your historical emails.

It is not required, but if you'd like to run this sync manually you can choose to do so. This allows you to temporarily interrupt it at any point and also restart if it gets stuck.

$ docker run -it --rm
    -v /path/to/config:/config \
    -v /path/to/mail:/mail \
    jakewharton/mbsync:1 \
    /app/sync.sh

This will run until all emails have been downloaded. At this point, you should set it up to run automatically on a schedule.

Running Automatically

To run the sync automatically on a schedule, pass a valid cron specifier as the CRON environment variable.

$ docker run -it --rm
    -v /path/to/config:/config \
    -v /path/to/mail:/mail \
    -e "CRON=0 * * * *" \
    jakewharton/mbsync:1

The above version will run every hour and download any new emails. For help creating a valid cron specifier, visit cron.help.

More

To be notified when sync is failing visit https://healthchecks.io, create a check, and specify the ID to the container using the HEALTHCHECK_ID environment variable.

Because the sync can occasionally fail, it's best to set a grace period on the check which is a multiple of your cron period. For example, if you run sync hourly give a grace period of two hours.

To write data as a particular user, the PUID and PGID environment variables can be set to your user ID and group ID, respectively.

Docker Compose

version: '2'
services:
  mbsync:
    image: jakewharton/mbsync:1
    restart: unless-stopped
    volumes:
      - /path/to/config:/config
      - /path/to/mail:/mail
    environment:
      - "CRON=0 * * * *"
      #Optional:
      - "HEALTHCHECK_ID=..."
      - "PUID=..."
      - "PGID=..."

See https://hub.docker.com/r/jakewharton/mbsync/tags for other tags.

LICENSE

MIT. See LICENSE.txt.

Copyright 2020 Jake Wharton

docker-mbsync's People

Contributors

chrisbanes avatar compeek avatar jakewharton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docker-mbsync's Issues

Container fails to restart until it is recreated

I use Docker Compose to run this mbsync container automatically.

However, after one of the recent updates, I noticed that the container errors out and won't start after I restart my computer. I think it probably happens anytime you stop the container and try to start it again actually.

The only fix is to delete the container and recreate it (docker-compose up -d --force-recreate).

It looks like the problem is that it's trying to add a user group that it already created the first time it ran. I'm guessing it would have the same problem with the user as well if it got that far.

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00_bootstrap.sh: executing...
[cont-init.d] 00_bootstrap.sh: exited 0.
[cont-init.d] 00_settimezone.sh: executing...
[cont-init.d] 00_settimezone.sh: exited 0.
[cont-init.d] 10-adduser.sh: executing...
addgroup: group 'abc' in use
[cont-init.d] 10-adduser.sh: exited 1.

I noticed you recently changed the commands used to create the group and user in [10-adduser.sh](https://github.com/JakeWharton/docker-mbsync/blob/trunk/root/etc/cont-init.d/10-adduser.sh), so I suspect the old commands were more tolerant of the group/user already existing and the new ones aren't.

Linking with dockerhub

Hi,
do you consider to link the github repo with the docker hub repo?

This would increase the integrity of the project. I know you're using github actions and therefore do not need the auto build of dockerhub. But as far as I know you can link the two anyways and still just use the github actions just as it is.

PUID PGID not working?

I'm using the following docker-compose but all emails are still written as root user.
Is PUID/PGID not working?

version: "3.4"
services:
  mbsync:
    image: jakewharton/mbsync:latest
    container_name: mbsync
    volumes:
      - /home/docker/mbsync:/config
      - /home/docker/mbsync/mail:/mail
    environment:
      - CRON="0 * * * *"
      #Optional:
      - "PUID=1000"
      - "PGID=1000"
    restart: unless-stopped
    command: /app/sync.sh
Initializing container
User uid: 1000
User gid: 1000
[cont-init.d] 10-adduser.sh: exited 0.
[cont-init.d] 20-cron.sh: executing... 
NOTE: Define HEALTHCHECK_ID with https://healthchecks.io to monitor sync job
Initializing cron
"0 * * * *"
[cont-init.d] 20-cron.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
INFO: Starting sync.sh PID 212 Thu Jun 17 14:09:06 UTC 2021
docker@docker01:~/mbsync/mail$ ls -l Inbox/cur
total 64692
-rw------- 1 root root   92443 Jun 17 16:02 '1623938567.225_10.7462ef4dcae5,U=10:2,S'
-rw------- 1 root root   37611 Jun 17 16:02 '1623938567.225_11.7462ef4dcae5,U=11:2,S'
-rw------- 1 root root   67230 Jun 17 16:02 '1623938567.225_12.7462ef4dcae5,U=12:2,S'
-rw------- 1 root root  237401 Jun 17 16:02 '1623938567.225_13.7462ef4dcae5,U=13:2,S'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.