joeyates / imap-backup

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

First run fails #139

Closed Rudiberto closed 1 year ago

Rudiberto commented 1 year ago

Run without root rights always fails. After running it with root access, it's sometimes possible without sudo.

Your workaround sudo chmod o+r /var/lib/gems/3.0.0/gems/mail-2.8.0/lib/*.rb fixed the issue. Here's the message I got:

/usr/lib/ruby/3.0.0/monitor.rb:108:insleep': Interrupt from /usr/lib/ruby/3.0.0/monitor.rb:108:in wait' from /usr/lib/ruby/3.0.0/monitor.rb:108:inwait_for_cond' from /usr/lib/ruby/3.0.0/monitor.rb:108:in wait' from /var/lib/gems/3.0.0/gems/net-imap-0.3.2/lib/net/imap.rb:1441:inget_tagged_response' from /var/lib/gems/3.0.0/gems/net-imap-0.3.2/lib/net/imap.rb:1502:in block in send_command' from /usr/lib/ruby/3.0.0/monitor.rb:202:insynchronize' from /usr/lib/ruby/3.0.0/monitor.rb:202:in mon_synchronize' from /var/lib/gems/3.0.0/gems/net-imap-0.3.2/lib/net/imap.rb:1484:insend_command' from /var/lib/gems/3.0.0/gems/net-imap-0.3.2/lib/net/imap.rb:1541:in block in search_internal' from /usr/lib/ruby/3.0.0/monitor.rb:202:insynchronize' from /usr/lib/ruby/3.0.0/monitor.rb:202:in mon_synchronize' from /var/lib/gems/3.0.0/gems/net-imap-0.3.2/lib/net/imap.rb:1537:insearch_internal' from /var/lib/gems/3.0.0/gems/net-imap-0.3.2/lib/net/imap.rb:1007:in uid_search' from /usr/lib/ruby/3.0.0/forwardable.rb:238:inuid_search' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/account/folder.rb:58:in uids' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/downloader.rb:95:inuids' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/downloader.rb:27:in run' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/account/connection.rb:64:inblock in run_backup' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/account/connection.rb:122:in block in each_folder' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/account/connection.rb:120:ineach' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/account/connection.rb:120:in each_folder' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/account/connection.rb:46:inrun_backup' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/cli/backup.rb:17:in block in run' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/cli/helpers.rb:91:inblock in each_connection' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/cli/helpers.rb:88:in each' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/cli/helpers.rb:88:ineach_connection' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/cli/backup.rb:16:in run' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/cli.rb:58:inbackup' from /var/lib/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in run' from /var/lib/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:ininvoke_command' from /var/lib/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in dispatch' from /var/lib/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:instart' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/bin/imap-backup:12:in block in <top (required)>' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/lib/imap/backup/logger.rb:34:insanitize_stderr' from /var/lib/gems/3.0.0/gems/imap-backup-8.0.2/bin/imap-backup:11:in <top (required)>' from /usr/local/bin/imap-backup:25:inload' from /usr/local/bin/imap-backup:25:in <main>'

joeyates commented 1 year ago

Hi @Rudiberto

I think the problem now is caused by file permissions on the backups themselves, caused by running imap-backup as root.

In general, for your use case, you shouldn't need to run the program as root, just run it as your regular user.

To fix the issue, you can either:

  1. check and correct the file permissions on your backup (see below),
  2. or, failing that, delete the old backup (but be careful what you delete!).

If you choose the second method, you will of course lose your existing backup, so the first method is preferable.

To set your user as the owner of all the backup files, open a terminal, change directory to the path where your backups are stored (default ~/.imap-backup) and issue the following command:

sudo chown -R $(id -u):$(id -g) *
Rudiberto commented 1 year ago

You have been completely right! Thank you a lot!

sudo chown -R $(id -u):$(id -g) * solved the problem and I feel so silly!

This version of imap-backup is even better, than the version (4.x.x) I used before.

Rudiberto commented 1 year ago

You have been completely right! Thank you a lot!

sudo chown -R $(id -u):$(id -g) * solved the problem and I feel so silly!

This version of imap-backup is even better, than the version (4.x.x) I used before.