imap-backup
Backup, restore and migrate email accounts.
Quick Start
brew install imap-backup # for macOS
gem install imap-backup # for Linux
imap-backup setup
imap-backup
Modes
There are two types of backups:
- Keep all (the default) - progressively saves a local copy of all emails,
- Mirror - adds and deletes emails from the local copy to keep it up to date with the account.
What You Can Do with a Backup
- Migrate - use the local copy to populate emails on another account. This is a once-only action that deletes any existing emails on the destination account.
- Mirror - make a destination account match the local copy. This action can be repeated.
- Restore - push the local copy back to the original account.
See below for a full list of commands.
Installation
Homebrew (macOS)
If you have Homebrew, do this:
brew install imap-backup
As a Ruby Gem
gem install imap-backup
If that doesn't work, see the detailed installation instructions.
From Source Code
If you want to use imap-backup directly from the source code, see here.
Setup
As a first step, you need to add accounts via a menu-driven command line program:
Run:
imap-backup setup
GMail
To use imap-backup with GMail, Office 365 and other services that require OAuth2 authentication, you can use email-oauth2-proxy to handle authentication, and then connect to the proxy on a local port.
Backup
Manually, from the command line:
imap-backup
Alternatively, add it to your crontab.
Backups can also be inspected, for example via local show and exported via utils export-to-thunderbird.
Commands
- backup
- local accounts
- local check
- local folders
- local list
- local show
- migrate
- mirror
- remote folders
- restore
- setup
- utils export-to-thunderbird
- utils ignore-history
For a full list of available commands, run
imap-backup help
For more information about a command, run
imap-backup help COMMAND
Performace
There are a couple of performance tweaks that you can use to improve backup speed.
These are activated via two settings:
- Global setting "Delay download writes"
- Account setting "Multi-fetch size"
As with all performance tweaks, there are trade-offs. If you are using a small virtual server or Raspberry Pi to run your backups, you will probably want to leave the default settings. If, on the other hand, you are using a computer with a fair bit of RAM, and you are dealing with a lot of email, then changing these settings may be worthwhile.
Delay download writes
This setting affects all account backups.
By default, imap-backup
uses the "delay metadata" strategy.
As messages are being backed-up, the message text
is written to disk, while the related metadata is stored in memory.
While this uses a little more memory, it avoids rewiting a growing JSON file for every message, speeding things up and reducing disk wear.
The alternative strategy, called "direct", writes everything to disk as it is received. This method is slower, but has the advantage of using slightly less memory, which may be important on very resource-limited systems, like Raspberry Pis.
Multi-fetch Size
By default, during backup, each message is downloaded one-by-one.
Using this setting, you can download chunks of emails at a time, potentially speeding up the process.
Using multi-fetch will mean that the backup process will use more memory - equivalent to the size of the groups of messages that are downloaded.
This behaviour may also exceed the rate limits on your email provider, so it's best to check before cranking it up!
Troubleshooting
If you have problems:
- ensure that you have the latest release,
- run
imap-backup
with the-v
or--verbose
parameter.
Development
See the Development documentation for notes on development and testing.
See the CHANGELOG to a list of changes that have been made in each release.