Backup.py issues - rtyaml package

I’ve noticed that backups haven’t run since moving to a brand new Ubuntu 22.04 box. I’ve tried to run it manually, but no luck.

ubuntu@mail01:~/mailinabox/management$ sudo python3 backup.py 
Traceback (most recent call last):
  File "/home/ubuntu/mailinabox/management/backup.py", line 12, in <module>
    import rtyaml
ModuleNotFoundError: No module named 'rtyaml'

Do I need to manually install the rtyaml package? If so, should I use pip to do it? I think that will require sudo permissions, so not sure if that will even work with the script.

Are you using a custom image of Ubuntu? AWS?

this could be something the Cloud provide broke somewhere along the way.

I used the AWS default Ubuntu AMI

Well, I manually installed it, and got feedback that it was already installed. :expressionless:

ubuntu@mail01:~$ sudo pip install rtyaml
Collecting rtyaml
  Downloading rtyaml-1.0.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from rtyaml) (5.4.1)
Installing collected packages: rtyaml
Successfully installed rtyaml-1.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

I was able to manually run a backup job, so at least it works now.

I take back the backup job being successful. The script runs, but there’s no output in the S3 bucket. What’s interesting is that I know the credentials work, because I performed a restore to this new box from the same S3 bucket a week or so ago.

./backup.py must be silently failing, as I do not receive any output.

ubuntu@mail01:~$ cd mailinabox/management/
ubuntu@mail01:~/mailinabox/management$ sudo ./backup.py 
ubuntu@mail01:~/mailinabox/management$ 

The rtyaml package is installed in the mailinabox pyhton env at /usr/local/lib/mailinabox/env/ Running python3 will use the wrong environment.
Try:

ubuntu@mail01:~$ cd mailinabox
ubuntu@mail01:~/mailinabox$ sudo ./management/backup.py 

Normally, the backup command is also quiet on success. Try with option --status, --verify or --list to see if it works

That helped, thank you. I can see backup files locally, but they aren’t stored in S3 (yet). Maybe that’s a weekly task done behind the scenes?

I have no experience with S3 but I believe the backup process should update the remote files every day. I guess something else is wrong here.
Stupid question: you configured mailinabox for S3, not for local?

You can use sudo management/backup.py --duplicity-command to obtain the backup command. Use the output to run the backup command and see if there’s errors.
First perform the export line, then use sudo -E to execute thr backup command. Use full instead of {command}

Thanks @KiekerJan this is closer. I now receive this error.

ubuntu@mail01:~/mailinabox$ duplicity full --archive-dir /home/user-data/backup/cache file:///home/user-data/backup/encrypted
gpg: WARNING: unsafe ownership on homedir '/home/ubuntu/.gnupg'
CommandLineError: Wrong number of positional args for 'full', got 1
Expected 2 positionals from ['file:///home/user-data/backup/encrypted'].

Is this on an ARM machine?

[edit] Also, this is an edited command? It does not include any S3 functionality.

No, x86. That’s the command that it spit out. This is a new box that was restored with mail and settings using Duplicity. My old box used S3 for backups. Maybe I need to reconfigure this new box to do that? I was under the assumption that all of the previous settings would carry over, but maybe this doesn’t.

I guess the larger issue is that the admin panel is still inaccessible, so I can’t go in and edit those settings easily.

Edit: This seemed to fix the admin panel issue.
sudo chmod 755 /usr/local/lib/mailinabox/vendor
sudo service nginx restart

Ok, now that the admin panel is fixed, we are getting somewhere.

ubuntu@mail01:~/mailinabox$ duplicity full --archive-dir /home/user-data/backup/cache --s3-endpoint-url https://s3.us-east-2.amazonaws.com s3://backup-mail01-xxxxx/mail-backup
gpg: WARNING: unsafe ownership on homedir '/home/ubuntu/.gnupg'
CommandLineError: Wrong number of positional args for 'full', got 1
Expected 2 positionals from ['s3://backup-mail01-xxxxx/mail-backup'].

Edit: Well, whatever. This was a journey. I re-ran sudo ./backup.py after setting the S3 stuff in the newly-fixed admin console. Seems to have worked.

Thanls @KiekerJan for prompting me in the right direction.