imap-backup 14.4.4 → 14.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +67 -137
  3. data/docs/documentation.md +19 -0
  4. data/imap-backup.gemspec +1 -1
  5. data/lib/imap/backup/account/backup.rb +2 -0
  6. data/lib/imap/backup/account/backup_folders.rb +7 -1
  7. data/lib/imap/backup/account/client_factory.rb +1 -0
  8. data/lib/imap/backup/account/folder.rb +26 -0
  9. data/lib/imap/backup/account/folder_backup.rb +4 -1
  10. data/lib/imap/backup/account/folder_ensurer.rb +3 -0
  11. data/lib/imap/backup/account/local_only_folder_deleter.rb +3 -1
  12. data/lib/imap/backup/account/restore.rb +2 -0
  13. data/lib/imap/backup/account/serialized_folders.rb +31 -1
  14. data/lib/imap/backup/account.rb +34 -18
  15. data/lib/imap/backup/cli/backup.rb +3 -0
  16. data/lib/imap/backup/cli/folder_enumerator.rb +6 -0
  17. data/lib/imap/backup/cli/helpers.rb +13 -0
  18. data/lib/imap/backup/cli/local/check.rb +3 -0
  19. data/lib/imap/backup/cli/local.rb +14 -1
  20. data/lib/imap/backup/cli/remote.rb +7 -0
  21. data/lib/imap/backup/cli/restore.rb +4 -0
  22. data/lib/imap/backup/cli/setup.rb +3 -0
  23. data/lib/imap/backup/cli/single/backup.rb +3 -0
  24. data/lib/imap/backup/cli/single.rb +4 -0
  25. data/lib/imap/backup/cli/stats.rb +3 -0
  26. data/lib/imap/backup/cli/transfer.rb +8 -0
  27. data/lib/imap/backup/cli/utils.rb +7 -1
  28. data/lib/imap/backup/cli.rb +8 -0
  29. data/lib/imap/backup/client/apple_mail.rb +2 -0
  30. data/lib/imap/backup/client/automatic_login_wrapper.rb +9 -1
  31. data/lib/imap/backup/client/default.rb +15 -4
  32. data/lib/imap/backup/configuration.rb +13 -0
  33. data/lib/imap/backup/configuration_not_found.rb +1 -0
  34. data/lib/imap/backup/downloader.rb +4 -0
  35. data/lib/imap/backup/email/mboxrd/message.rb +14 -0
  36. data/lib/imap/backup/email/provider/apple_mail.rb +2 -0
  37. data/lib/imap/backup/email/provider/base.rb +3 -3
  38. data/lib/imap/backup/email/provider/fastmail.rb +2 -0
  39. data/lib/imap/backup/email/provider/gmail.rb +2 -0
  40. data/lib/imap/backup/email/provider/purelymail.rb +2 -0
  41. data/lib/imap/backup/email/provider/unknown.rb +2 -6
  42. data/lib/imap/backup/email/provider.rb +5 -0
  43. data/lib/imap/backup/file_mode.rb +2 -0
  44. data/lib/imap/backup/flag_refresher.rb +4 -0
  45. data/lib/imap/backup/local_only_message_deleter.rb +2 -0
  46. data/lib/imap/backup/logger.rb +18 -0
  47. data/lib/imap/backup/migrator.rb +3 -0
  48. data/lib/imap/backup/mirror/map.rb +21 -0
  49. data/lib/imap/backup/mirror.rb +8 -0
  50. data/lib/imap/backup/naming.rb +10 -1
  51. data/lib/imap/backup/retry_on_error.rb +9 -0
  52. data/lib/imap/backup/serializer/appender.rb +9 -0
  53. data/lib/imap/backup/serializer/delayed_metadata_serializer.rb +4 -0
  54. data/lib/imap/backup/serializer/folder_maker.rb +1 -0
  55. data/lib/imap/backup/serializer/imap.rb +38 -2
  56. data/lib/imap/backup/serializer/integrity_checker.rb +1 -0
  57. data/lib/imap/backup/serializer/mbox.rb +26 -0
  58. data/lib/imap/backup/serializer/message.rb +13 -0
  59. data/lib/imap/backup/serializer/message_enumerator.rb +10 -2
  60. data/lib/imap/backup/serializer/permission_checker.rb +6 -0
  61. data/lib/imap/backup/serializer/transaction.rb +18 -0
  62. data/lib/imap/backup/serializer/unused_name_finder.rb +4 -0
  63. data/lib/imap/backup/serializer/version2_migrator.rb +4 -0
  64. data/lib/imap/backup/serializer.rb +56 -2
  65. data/lib/imap/backup/setup/account/header.rb +6 -0
  66. data/lib/imap/backup/setup/account.rb +6 -0
  67. data/lib/imap/backup/setup/asker.rb +16 -0
  68. data/lib/imap/backup/setup/backup_path.rb +6 -0
  69. data/lib/imap/backup/setup/connection_tester.rb +5 -0
  70. data/lib/imap/backup/setup/email_changer.rb +6 -0
  71. data/lib/imap/backup/setup/folder_chooser.rb +4 -0
  72. data/lib/imap/backup/setup/global_options/download_strategy_chooser.rb +4 -0
  73. data/lib/imap/backup/setup/global_options.rb +4 -0
  74. data/lib/imap/backup/setup/helpers.rb +3 -0
  75. data/lib/imap/backup/setup.rb +5 -0
  76. data/lib/imap/backup/text/sanitizer.rb +9 -0
  77. data/lib/imap/backup/thunderbird/mailbox_exporter.rb +8 -1
  78. data/lib/imap/backup/uploader.rb +5 -0
  79. data/lib/imap/backup/version.rb +7 -2
  80. metadata +11 -13
  81. data/docs/api.md +0 -20
  82. data/docs/development.md +0 -110
  83. data/docs/migrate-server-keep-address.md +0 -47
@@ -7,7 +7,11 @@ module Imap; end
7
7
  module Imap::Backup
8
8
  class Thunderbird; end
9
9
 
10
+ # Exports an account's emails to Thunderbird
10
11
  class Thunderbird::MailboxExporter
12
+ # @param email [String] an email address
13
+ # @param serializer [Serializer] a local folder backup
14
+ # @param profile [Thunderbird::Profile] an existing Thunderbird profile
11
15
  def initialize(email, serializer, profile, force: false)
12
16
  @email = email
13
17
  @serializer = serializer
@@ -15,6 +19,9 @@ module Imap::Backup
15
19
  @force = force
16
20
  end
17
21
 
22
+ # Copies the account's messages to the Thunderbird directory
23
+ # in the format expected by Thunderbird
24
+ # @return [void]
18
25
  def run
19
26
  if !profile_set_up
20
27
  error "The Thunderbird profile '#{profile.title}' " \
@@ -97,7 +104,7 @@ module Imap::Backup
97
104
  @local_folder ||= begin
98
105
  top_level_folders = [EXPORT_PREFIX, email]
99
106
  prefixed_folder_path = File.join(top_level_folders, serializer.folder)
100
- ::Thunderbird::LocalFolder.new(profile, prefixed_folder_path)
107
+ ::Thunderbird::LocalFolder.new(profile: profile, path: prefixed_folder_path)
101
108
  end
102
109
  end
103
110
 
@@ -5,12 +5,17 @@ require "imap/backup/serializer"
5
5
  module Imap; end
6
6
 
7
7
  module Imap::Backup
8
+ # Uploads a backed-up folder
8
9
  class Uploader
10
+ # @param folder [Account::Folder] an online folder
11
+ # @param serializer [Serializer] a local folder backup
9
12
  def initialize(folder, serializer)
10
13
  @folder = folder
11
14
  @serializer = serializer
12
15
  end
13
16
 
17
+ # Uploads messages that are present in the backup, but not in the online folder
18
+ # @return [void]
14
19
  def run
15
20
  if folder.uids.any?
16
21
  rename_serialized_folder
@@ -1,9 +1,14 @@
1
1
  module Imap; end
2
2
 
3
3
  module Imap::Backup
4
+ # @private
4
5
  MAJOR = 14
5
- MINOR = 4
6
- REVISION = 4
6
+ # @private
7
+ MINOR = 5
8
+ # @private
9
+ REVISION = 0
10
+ # @private
7
11
  PRE = nil
12
+ # The application version
8
13
  VERSION = [MAJOR, MINOR, REVISION, PRE].compact.map(&:to_s).join(".")
9
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imap-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.4.4
4
+ version: 14.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Yates
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-17 00:00:00.000000000 Z
11
+ date: 2024-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: thunderbird
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 0.0.0
117
+ version: 0.3.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 0.0.0
124
+ version: 0.3.0
125
125
  description: Backup GMail, or any other IMAP email service, to disk.
126
126
  email:
127
127
  - joe.g.yates@gmail.com
@@ -133,10 +133,8 @@ files:
133
133
  - LICENSE
134
134
  - README.md
135
135
  - bin/imap-backup
136
- - docs/api.md
137
136
  - docs/delimiters-and-prefixes.md
138
- - docs/development.md
139
- - docs/migrate-server-keep-address.md
137
+ - docs/documentation.md
140
138
  - docs/performance.md
141
139
  - imap-backup.gemspec
142
140
  - lib/imap/backup/account.rb
@@ -220,7 +218,7 @@ licenses:
220
218
  - MIT
221
219
  metadata:
222
220
  rubygems_mfa_required: 'true'
223
- post_install_message:
221
+ post_install_message:
224
222
  rdoc_options: []
225
223
  require_paths:
226
224
  - lib
@@ -235,8 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
233
  - !ruby/object:Gem::Version
236
234
  version: '0'
237
235
  requirements: []
238
- rubygems_version: 3.3.7
239
- signing_key:
236
+ rubygems_version: 3.4.10
237
+ signing_key:
240
238
  specification_version: 4
241
239
  summary: Backup GMail (or other IMAP) accounts to disk
242
240
  test_files: []
data/docs/api.md DELETED
@@ -1,20 +0,0 @@
1
- # @title Index
2
- # imap-backup API Documentation
3
-
4
- ![Version](https://img.shields.io/gem/v/imap-backup?label=Version&logo=rubygems)
5
- [![Build Status](https://github.com/joeyates/imap-backup/actions/workflows/main.yml/badge.svg)][CI Status]
6
- ![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/joeyates/b54fe758bfb405c04bef72dad293d707/raw/coverage.json)
7
- ![License](https://img.shields.io/github/license/joeyates/imap-backup?color=brightgreen&label=License)
8
- [![Stars](https://img.shields.io/github/stars/joeyates/imap-backup?style=social)][GitHub Stars]
9
-
10
- [CI Status]: https://github.com/joeyates/imap-backup/actions/workflows/main.yml
11
- [GitHub Stars]: https://github.com/joeyates/imap-backup/stargazers "GitHub Stars"
12
-
13
- This is the developer documentation for imap-backup's **code**.
14
-
15
- Usage documentation is on [GitHub](https://github.com/joeyates/imap-backup).
16
-
17
- You can get an overview of the program's structure from the
18
- {file:ARCHITECTURE.md ARCHITECTURE} file.
19
-
20
- The {file:CHANGELOG.md CHANGELOG} has a history of the changes to the program.
data/docs/development.md DELETED
@@ -1,110 +0,0 @@
1
- # Repository
2
-
3
- After cloning the repo, run the following command to get
4
- better `git blame` output:
5
-
6
- ```sh
7
- git config --local blame.ignoreRevsFile .git-blame-ignore-revs
8
- ```
9
-
10
- # Design Goals
11
-
12
- * Secure - use a local configuration file protected by permissions
13
- * Restartable - calculate start point based on already downloaded messages
14
- * Standalone - do not rely on an email client or MTA
15
-
16
- # Testing
17
-
18
- ## Feature Specs
19
-
20
- Specs under `specs/features` are integration specs.
21
- Some of these specs run against two local IMAP servers
22
- controlled by Podman (or Docker) Compose.
23
-
24
- Start them before running the test suite
25
-
26
- ```sh
27
- $ podman-compose -f dev/compose.yml up -d
28
- ```
29
-
30
- or, with Podman
31
-
32
- ```sh
33
- $ podman-compose -f dev/compose.yml up -d
34
- ```
35
-
36
- Then, run all specs
37
-
38
- ```sh
39
- $ rspec
40
- ```
41
-
42
- To exclude container-based tests
43
-
44
- ```sh
45
- $ rspec --tag ~docker
46
- ```
47
-
48
- To run **just** the feature specs
49
-
50
- ```sh
51
- rspec spec/features/**/*_spec.rb
52
- ```
53
-
54
- ## Full Test Run
55
-
56
- The full test run includes RSpec specs **and** Runbocop checks
57
-
58
- ```sh
59
- rake
60
- ```
61
-
62
- # Older Rubies
63
-
64
- A Containerfile is available to allow testing with all available Ruby versions,
65
- see the README in the `dev` directory.
66
-
67
- # Performance Specs
68
-
69
- ```sh
70
- PERFORMANCE=1 rspec --order=defined
71
- ```
72
-
73
- Beware: the performance spec (just backup for now) takes a very
74
- long time to run, approximately 24 hours!
75
-
76
- ### Debugging
77
-
78
- The feature specs are run 'out of process' via the Aruba gem.
79
- In order to see debugging output from the process,
80
- use `last_command_started.output`.
81
-
82
- ## Access Docker imap server
83
-
84
- ```ruby
85
- require "net/imap"
86
- require_relative "spec/features/support/30_email_server_helpers"
87
-
88
- include EmailServerHelpers
89
-
90
- test_connection = test_server_connection_parameters
91
-
92
- test_imap = Net::IMAP.new(test_connection[:server], test_connection[:connection_options])
93
- test_imap.login(test_connection[:username], test_connection[:password])
94
-
95
- message = "From: #{test_connection[:username]}\nSubject: Some Subject\n\nHello!\n"
96
- response = test_imap.append("INBOX", message, nil, nil)
97
-
98
- test_imap.examine("INBOX")
99
- uids = test_imap.uid_search(["ALL"]).sort
100
-
101
- fetch_data_items = test_imap.uid_fetch(uids, ["BODY[]"])
102
- ```
103
-
104
- # Contributing
105
-
106
- 1. Fork it
107
- 2. Create your feature branch (`git checkout -b my-new-feature`)
108
- 3. Commit your changes (`git commit -am 'Added some feature'`)
109
- 4. Push to the branch (`git push origin my-new-feature`)
110
- 5. Create new Pull Request
@@ -1,47 +0,0 @@
1
- # Migrate to a new e-mail server while keeping your existing address
2
-
3
- While switching e-mail provider (from provider `A` to `B`),
4
- you might want to keep the same address (`mymail@domain.com`),
5
- and copy all your existing e-mails to your new server `B`.
6
- `imap-backup` can do that too!
7
-
8
- It is best to use [`imap-backup migrate`](/docs/commands/migrate.md)
9
- and not [`imap-backup restore`](/docs/commands/restore.md) here because
10
- `migrate` simply copies emails to folders with the same name as the ones
11
- they were downloaded from, while `restore` changes the names of restored
12
- folders if folders with the same name already exist on the destination server.
13
-
14
- 1. Backup your e-mails: use [`imap-backup setup`](/docs/commands/setup.md)
15
- to setup connection to your old provider `A`,
16
- then launch [`imap-backup backup`](/docs/commands/backup.md).
17
- 1. Actually switch your e-mail service provider (update your DNS MX and all that...).
18
- 1. As both the source and the destination have the same address,
19
- you need to manually rename your old account first:
20
-
21
- 1. Modify your configuration file manually
22
- (i.e. not via `imap-backup setup`) and
23
- rename your account to `mymail-old@domain.com`:
24
-
25
- ```diff
26
- "accounts": [
27
- {
28
- - "username": "mymail@domain.com",
29
- + "username": "mymail-old@domain.com",
30
- "password": "...",
31
- - "local_path": "/some/path/.imap-backup/mymail_domain.com",
32
- + "local_path": "/some/path/.imap-backup/mymail-old_domain.com",
33
- "folders": [...],
34
- "server": "..."
35
- }
36
- ```
37
-
38
- 1. Rename the backup directory from `mymail_domain.com`
39
- to `mymail-old_domain.com`.
40
-
41
- 1. Set up a new account giving access to the new provider `B`
42
- using `imap-backup setup`.
43
- 1. Now you can use `imap-backup migrate`, optionally adapting
44
- [delimiters and prefixes configuration](/docs/delimiters-and-prefixes.md)
45
- if need be:
46
-
47
- imap-backup migrate mymail-old@domain.com mymail@domain.com [options]