GithubHelp home page GithubHelp logo

psad73 / imap-backup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joeyates/imap-backup

0.0 0.0 0.0 1.67 MB

Backup GMail (or other IMAP) accounts to disk

License: MIT License

Ruby 100.00%

imap-backup's Introduction

Version Build Status Coverage License

imap-backup

Backup GMail (or other IMAP) accounts to disk

Installation

$ gem install 'imap-backup'

Commands

For a full list, run

$ imap-backup help

For more information about a command, run

$ imap-backup help COMMAND

Setup

In order to do backups, you need to add accounts via a menu-driven command line program:

Run:

$ imap-backup setup

GMail

To use imap-backup with GMail, you will need to enable 'App passwords' on your account.

Folders

By default, all folders are backed-up. You can override this by choosing specific folders.

Configuration file

setup creates the file ~/.imap-backup/config.json

E.g.:

{
  "accounts": [
    {
      "username": "[email protected]",
      "password": "secret",
      "local_path": "/path/to/backup/root",
      "folders":
        [
          {"name": "[Gmail]/All Mail"},
          {"name": "my_folder"}
        ]
    }
  ]
}

It connects to GMail by default, but you can also specify a server:

{
  "accounts": [
    {
      "username": "[email protected]",
      "password": "secret",
      "server": "my.imap.example.com",
      "local_path": "/path/to/backup/root",
      "folders":
        [
          {"name": "[Gmail]/All Mail"},
          {"name": "my_folder"}
        ]
    }
  ]
}

Connection options

You can override the parameters passed to Net::IMAP with connection_options.

Specifically, if you are using a self-signed certificate and get SSL errors, e.g. certificate verify failed, you can choose to not verify the TLS connection:

{
  "accounts": [
    {
      "username": "[email protected]",
      "password": "secret",
      "server": "my.imap.example.com",
      "local_path": "/path/to/backup/root",
      "folders": [
        {"name": "[Gmail]/All Mail"},
        {"name": "my_folder"}
      ],
      "connection_options": {
        "ssl": {"verify_mode": 0},
        "port": 993
      }
    }
  ]
}

Security

Note that email usernames and passwords are held in plain text in the configuration file.

The directory ~/.imap-backup, the configuration file and all backup directories have their access permissions set to only allow access by your user. This is not done on Windows - see below.

Windows

Due to the complexity of managing permissions on Windows, directory and file access permissions are not set explicity.

A pull request that implements permissions management on Windows would be welcome!

Run Backup

Manually, from the command line:

$ imap-backup

Alternatively, add it to your crontab.

Result

Each folder is saved to an mbox file. Alongside each mbox is a file with extension '.imap', which lists the source IMAP UIDs to allow a full restore.

Local commands

There a various commands for viewing local backup status.

To view the list, use

$ imap_backup help local

Troubleshooting

If you have problems:

  1. ensure that you have the latest release,
  2. turn on debugging output:
{
  "accounts":
  [
    ...
  ],
  "debug": true
}

Restore

All missing messages are pushed to the IMAP server. Existing messages are left unchanged.

This functionality requires that the IMAP server supports the UIDPLUS extension to IMAP4.

Other Usage

List IMAP folders:

$ imap-backup folders

Get statistics of emails to download per folder:

$ imap-backup status

Design Goals

  • Secure - use a local file protected by permissions
  • Restartable - calculate start point based on already downloaded messages
  • Standalone - do not rely on an email client or MTA

Documentation

imap-backup's People

Contributors

joeyates avatar a-krebs avatar jmechnich avatar boltronics avatar andreynering avatar sigmike avatar olleolleolle avatar

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.