Virtualmin Backup Deletion Error Over SSH with Custom Port

SYSTEM INFORMATION
OS type and version Rocky 9.6
Webmin version 2.500
Virtualmin version 7.40.0
Webserver version apache 2.4.62

I set up a scheduled backup via SSH. In the Destination and format section, I only configured the following two settings:

> SSH/SFTP-enabled server: test:4444
> Directory on server: /home/backups/%Y-%m-%d

My root/.ssh/config file is configured as follows:

Host test
HostName test.com
User root
Port 4444

I can connect to ssh test via the console without any issues. The backup process itself also works fine.

However, when it comes to deleting old backups, I get the following error. I think this might be related to the port configuration, but despite trying several different approaches, I couldn’t figure it out.

7 Virtualmin system configurations backed up successfully
Deleting backups from /home/backups on SSH server test matching .-.-.* older than 60 days ..
.. failed to list directory via SSH : usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
[-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
[-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
[-i identity_file] [-J [user@]host[:port]] [-L address]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] destination [command]

Thanks for the heads up!

@Jamie, it does seem like a bug!

@uyesercan Can you check “Webmin ⇾ Webmin Actions Log” for the latest backup operation and see which command fails exactly? You can use a toggle at the top right of the “Action Details” page to remove backslashes from executed commands for better readability.

Thanks @Ilia

Here is my screenshot from the related Action logs. I just manipulated the site names (site1, site2) and ssh name (test) for security.

This looks like a bug, but I wasn’t able to reproduce it with Virtualmin 7.40.

Can you post the output of the command virtualmin list-scheduled-backups --multiline on your system?

@Jamie thanks.

Here is my output.
FYI, I have replaced real site names (e.g., site1, site2) and SSH usernames (e.g., test) for security reasons.

[root@konsole ~]# virtualmin list-scheduled-backups --multiline
175589024077601
    Domains: Except site1.com db.site2.com
    Include sub-servers: Yes
    Virtualmin configs: config templates email custom scripts scheds mailserver
    Destination: ssh://:@test:4444:/home/backups/%Y-%m-%d
    Delete old backups after: 60 days
    Features: All
    Format: One file per server
    Differential: No
    Enabled: Yes
    Send email: Always
    Notify domain owners: No
    Running: No
1755811344134046
    Domains: site1.com
    Include sub-servers: Yes
    Virtualmin configs: config templates email custom scripts scheds mailserver
    Destination: ssh://:@test:4444:/home/backups/%Y-%m-%d
    Delete old backups after: 60 days
    Features: All
    Format: One file per server
    Differential: No
    Enabled: Yes
    Send email: Always
    Notify domain owners: No
    Running: No

Thanks, that’s exactly what I needed. Turns out that if no username is entered for the SSH destination, the purging code constructs the wrong SSH command.

The fix will be in the next release, and can be seen here:

@uyesercan You can apply this patch, re-save the scheduled backup form, and see if it works for you this time:

webmin patch https://github.com/virtualmin/virtualmin-gpl/commit/9c1088d

I applied your fix to my backups-lib.pl and it looks like it’s working perfectly now.

Thanks @Ilia @Jamie

image

Here is the result:

image

You’re welcome! Can you also post virtualmin list-scheduled-backups --multiline output one last time to make it easier for future readers?

Interestingly, the output is still exactly the same as before (checked with KDiff3).

By the way, I’m not sure if it’s related, but when I search for the modified line ($user.“@”.$host;), I also see the same code on line 7037.

Good catch! I fixed that here : Fix another case where user may be empty · virtualmin/virtualmin-gpl@9c3fb77 · GitHub

What about execute_command_via_ssh function?

Thanks I’ll fix that one too.

2 Likes

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.