joeyates / imap-backup

Backup and Migrate IMAP Email Accounts
MIT License
1.37k stars 75 forks source link

restore fails #115

Closed damnms closed 2 years ago

damnms commented 2 years ago

hi, i created a backup for multiple inboxes and tried to restore now one of them, but that failed:

[oli@DESKTOP-E83VF5L .imap-backup]$ imap-backup restore some@example.com
D, [2022-02-24T09:39:24.551324 #16035] DEBUG -- : Creating IMAP instance: mx2f2c.netcup.net, options: {:port=>993, :ssl=>{:ssl_version=>:TLSv1_2}}
D, [2022-02-24T09:39:24.551369 #16035] DEBUG -- : Logging in: some@example.com/xxxxxxxxxxxxx
S: * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ AUTH=PLAIN AUTH=LOGIN AUTH=DIGEST-MD5 AUTH=CRAM-MD5] Dovecot ready.
C: RUBY0001 LOGIN some@example.com [PASSWORD REDACTED]
S: RUBY0001 OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY SPECIAL-USE QUOTA] Logged in
D, [2022-02-24T09:39:24.674647 #16035] DEBUG -- : Login complete
C: RUBY0002 EXAMINE Archive
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691815] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0002 OK [READ-ONLY] Examine completed (0.010 + 0.020 + 0.029 secs).
C: RUBY0003 UID SEARCH ALL
S: * SEARCH
S: RUBY0003 OK Search completed (0.001 + 0.020 secs).
C: RUBY0004 EXAMINE Archive
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691815] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0004 OK [READ-ONLY] Examine completed (0.002 + 0.020 + 0.020 secs).
C: RUBY0005 EXAMINE Archive
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691815] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0005 OK [READ-ONLY] Examine completed (0.002 + 0.020 + 0.020 secs).
C: RUBY0006 EXAMINE Archive
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691815] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0006 OK [READ-ONLY] Examine completed (0.001 + 0.020 + 0.019 secs).
C: RUBY0007 UID SEARCH ALL
S: * SEARCH
S: RUBY0007 OK Search completed (0.001 + 0.020 secs).
C: RUBY0008 EXAMINE Archives
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691814] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0008 OK [READ-ONLY] Examine completed (0.002 + 0.020 + 0.020 secs).
C: RUBY0009 UID SEARCH ALL
S: * SEARCH
S: RUBY0009 OK Search completed (0.001 + 0.020 secs).
C: RUBY0010 EXAMINE Archives
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691814] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0010 OK [READ-ONLY] Examine completed (0.001 + 0.020 + 0.020 secs).
C: RUBY0011 EXAMINE Archives
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691814] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0011 OK [READ-ONLY] Examine completed (0.001 + 0.020 + 0.020 secs).
C: RUBY0012 EXAMINE Archives
S: * OK [CLOSED] Previous mailbox closed.
S: * FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
S: * OK [PERMANENTFLAGS ()] Read-only mailbox.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDVALIDITY 1645691814] UIDs valid
S: * OK [UIDNEXT 1] Predicted next UID
S: RUBY0012 OK [READ-ONLY] Examine completed (0.002 + 0.020 + 0.020 secs).
C: RUBY0013 UID SEARCH ALL
S: * SEARCH
S: RUBY0013 OK Search completed (0.001 + 0.020 secs).
C: RUBY0014 EXAMINE Drafts.1629893906
S: * OK [CLOSED] Previous mailbox closed.
S: RUBY0014 NO [CANNOT] Character not allowed in mailbox name: '.' (0.001 + 0.020 + 0.019 secs).
W, [2022-02-24T09:39:25.204848 #16035]  WARN -- : Folder 'Drafts.1629893906' does not exist on server
C: RUBY0015 EXAMINE Drafts.1629893906
S: RUBY0015 NO [CANNOT] Character not allowed in mailbox name: '.' (0.001 + 0.020 + 0.019 secs).
W, [2022-02-24T09:39:25.244119 #16035]  WARN -- : Folder 'Drafts.1629893906' does not exist on server
C: RUBY0016 CREATE Drafts.1629893906
S: RUBY0016 NO [CANNOT] Character not allowed in mailbox name: '.' (0.001 + 0.020 + 0.019 secs).
/usr/share/ruby/net/imap.rb:1224:in `get_tagged_response':  Character not allowed in mailbox name: '.' (0.001 + 0.020 + 0.019 secs). (Net::IMAP::NoResponseError)
    from /usr/share/ruby/net/imap.rb:1278:in `block in send_command'
    from /usr/share/ruby/monitor.rb:202:in `synchronize'
    from /usr/share/ruby/monitor.rb:202:in `mon_synchronize'
    from /usr/share/ruby/net/imap.rb:1260:in `send_command'
    from /usr/share/ruby/net/imap.rb:483:in `create'
    from /usr/share/ruby/forwardable.rb:238:in `create'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/folder.rb:43:in `create'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/connection.rb:173:in `restore_folder'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/connection.rb:97:in `block in restore'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/connection.rb:91:in `block in local_folders'
    from <internal:dir>:134:in `glob'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/connection.rb:87:in `glob'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/connection.rb:87:in `local_folders'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/account/connection.rb:96:in `restore'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/cli/restore.rb:22:in `run'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/cli.rb:116:in `restore'
    from /home/oli/.local/share/gem/ruby/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /home/oli/.local/share/gem/ruby/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /home/oli/.local/share/gem/ruby/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /home/oli/.local/share/gem/ruby/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/bin/imap-backup:10:in `block in <top (required)>'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/lib/imap/backup/logger.rb:29:in `sanitize_stderr'
    from /home/oli/.local/share/gem/ruby/gems/imap-backup-5.1.0/bin/imap-backup:9:in `<top (required)>'
    from /home/oli/bin/imap-backup:23:in `load'
    from /home/oli/bin/imap-backup:23:in `<main>'
joeyates commented 2 years ago

Hi @damnms

Thanks for reporting the issue. This is an issue with compatibility with the server - imap-backup currently assumes it can create mailboxes with "." in the name, which is true of most, but not all mail servers.

I'll have a look asap.

damnms commented 2 years ago

you are right, just tried to create that folder on the server and got the same error, so its a problem with netcup

thanks for the ultra fast response :)

joeyates commented 2 years ago

Hi @damnms Actually, imap-backup should be able to handle this! I'm going to look at a fix, so I'll repoen :)

joeyates commented 2 years ago

I've release version 5.2.0 which no longer uses '.' when renaming folders when it sees conflicts with the server.

Let me know if it fixes the problem.