joeyates / imap-backup

Backup and Migrate IMAP Email Accounts
MIT License
1.33k stars 74 forks source link

Restore does not accept a `--delimiter` parameter #196

Closed klando closed 5 months ago

klando commented 5 months ago

Apparently I hit a bug related to WARN -- : Folder 'Archives/2010' does not exist on server: gem/ruby/3.1.0/gems/net-imap-0.4.9.1/lib/net/imap.rb:2708: in get_tagged_response': Invalid mailbox name: Name must not have '/' characters (0.001 + 0.060 + 0.059 secs). (Net::IMAP::NoResponseError)

On linux, with gem install imap-backup --no-document --user-install

With a large folder tree (thought no more than 3 levels I think).

full trace:

W, [2024-01-30T00:42:23.861158 #956808]  WARN -- : Folder 'Archives/2010' does not exist on server
W, [2024-01-30T00:42:23.861299 #956808]  WARN -- : gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/folder.rb:186:in `examine'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/folder.rb:72:in `uids'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/uploader.rb:20:in `run'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/restore.rb:20:in `block in run'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/serialized_folders.rb:31:in `block in each'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/serialized_folders.rb:27:in `each'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/serialized_folders.rb:27:in `each'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/restore.rb:19:in `run'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account.rb:106:in `restore'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/cli/restore.rb:31:in `run'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/cli.rb:236:in `restore'
gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/cli.rb:69:in `start'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/bin/imap-backup:16:in `block in <top (required)>'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/logger.rb:58:in `sanitize_stderr'
gem/ruby/3.1.0/gems/imap-backup-14.5.2/bin/imap-backup:15:in `<top (required)>'
gem/ruby/3.1.0/bin/imap-backup:25:in `load'
gem/ruby/3.1.0/bin/imap-backup:25:in `<main>'
gem/ruby/3.1.0/gems/net-imap-0.4.9.1/lib/net/imap.rb:2708:in `get_tagged_response': Invalid mailbox name: Name must not have '/' characters (0.001 + 0.060 + 0.059 secs). (Net::IMAP::NoResponseError)
        from gem/ruby/3.1.0/gems/net-imap-0.4.9.1/lib/net/imap.rb:2794:in `block in send_command'
        from /usr/lib/ruby/3.1.0/monitor.rb:202:in `synchronize'
        from /usr/lib/ruby/3.1.0/monitor.rb:202:in `mon_synchronize'
        from gem/ruby/3.1.0/gems/net-imap-0.4.9.1/lib/net/imap.rb:2776:in `send_command'
        from gem/ruby/3.1.0/gems/net-imap-0.4.9.1/lib/net/imap.rb:1432:in `create'
        from /usr/lib/ruby/3.1.0/forwardable.rb:238:in `create'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/client/automatic_login_wrapper.rb:28:in `method_missing'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/folder.rb:55:in `block in create'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/retry_on_error.rb:18:in `retry_on_error'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/folder.rb:54:in `create'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/uploader.rb:23:in `run'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/restore.rb:20:in `block in run'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/serialized_folders.rb:31:in `block in each'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/serialized_folders.rb:27:in `each'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/serialized_folders.rb:27:in `each'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account/restore.rb:19:in `run'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/account.rb:106:in `restore'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/cli/restore.rb:31:in `run'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/cli.rb:236:in `restore'
        from gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
        from gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
        from gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
        from gem/ruby/3.1.0/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/cli.rb:69:in `start'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/bin/imap-backup:16:in `block in <top (required)>'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/lib/imap/backup/logger.rb:58:in `sanitize_stderr'
        from gem/ruby/3.1.0/gems/imap-backup-14.5.2/bin/imap-backup:15:in `<top (required)>'
        from gem/ruby/3.1.0/bin/imap-backup:25:in `load'
        from gem/ruby/3.1.0/bin/imap-backup:25:in `<main>'
joeyates commented 5 months ago

Hi @klando

You didn't include the command :) But, from the backtrace it looks like you're doing a restore.

The server you're restoring to does not use / as its "delimiter" - the separator between folder and subfolder names - it probably uses .

Unfortunately, imap-backup does not yet have an option for specifying the delimiter when running restore.

As a hacky workaround, you could use the restore command, which accepts a --destination-delimiter parameter - YMMV.

See this HOWTO.

To see which delimiter your provider uses, run the namespaces command:

imap-backup remote namespaces me@example.com -c config/my-config.json 
Name       Prefix     Delimiter
personal   ""         "."
other      (Not defined)
shared     (Not defined)

Here . is the delimiter.

klando commented 5 months ago

Hey @joeyates Tks for your software, amazing. About the restore, I didn't see a --destination-delimiter though... As a workaround I have renamed and reorganized files here.

My use case is that I had to migrate accounts without any option to have both imap servers up at the same time, no inter-connection available.

I didn't explore all options of imap-backup but I came to the conclusion that it's not the design and it's better to mirror accounts to change delimiters and all (well let it do automatically).. So I'm arranging for a 2 steps migration via a third IMAP instead of having backup files...

klando commented 5 months ago

btw I basically ended up doing exactly what's written in the howto...

joeyates commented 5 months ago

Reopening as the --delimiter flag needs to be added to restore

joeyates commented 5 months ago

The --delimiter parameter (alongside --prefix) is now available from version 14.6.0