A simple Mail backup solution
- Ruby 3.4.5+
- any shell and terminal
- an email account to back up accessible via IMAP (+SSL)
- Download and extract a release
- From the extracted download folder, run
bundle install - (Optional) Add
backMailto your path - Done
- Download, extract and install a release
- Done
From a terminal, run (change the path to backMail according to your situation):
./backMail -e your@email.com -p 'your password' -s imap-server.email.com
Note: only
passwordandimap_serverare mandatory values.You can run
./backMail -hto display the help, there is many more options to discover
You can set an account config file using a YAML file instead of using command lines options. The file should be like:
email: "your-email@example.com"
password: "your-password"
imap_server: "imap.example.com"
imap_port: 993
output_dir: "/path/to/output/dir"Note: Again, only
passwordandimap_serverare mandatory values.Security Note: there is a password in this files, so, pay attention where you upload it and to prevent leak, this file should be read/write (even better, this file can be read only) only for the user who run this app. You can achieve this under
macOS,GNU Linuxand*BSDby changing the permission likechmod go-rwx my_config_file.yaml.
If you want to back up multiple accounts, you can create multiple config file, one per account and create a cron task to automate this process.
Example with this two accounts: account_1@example.com and account_2@example.com, assuming backMail is installed
and in your PATH.
-
Create two
YAMLconfig files:-
One named
account_1.yamlemail: "account_1@example.com" password: "super secured password" imap_server: "imap.example.com"
-
The other named
account_2.yamlemail: "account_2@example.com" password: "another secured password" imap_server: "imap.example.com"
-
-
And create two
crontask- Task for
account_1.yaml, every day at 5 pm:echo "0 17 * * * backMail -c ~/.config/account_1.yaml" | crontab - - Task for
account_2.yaml, every day, every 5 minutes, with logs output into a file:echo "*/5 * * * * backMail -c ~/another/random/path/account_2.yaml >> ~/.local/share/backMail_account_2.log 2>&1" | crontab -
- Task for
- Add a toggle to disable save of attachments
- Add shell completion (BASH, zsh, fish, powershell)
- Add a man page
- Add examples and documentation here 🤦♂️