# Old SFTP Backups Are Not Deleted Because Destination Directory Is Duplicated

**URL:** <https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548>\
**Category:** Help! (Home for newbies)\
**Created:** [July 10, 2026, 1:58pm UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548 "2026-07-10T13:58:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![metrics](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@metrics](https://forum.virtualmin.com/u/metrics)\
**Post date:** [July 10, 2026, 1:58pm UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548/1 "2026-07-10T13:58:38Z")

</div>

| SYSTEM INFORMATION | |
| --- | --- |
| OS type and version | AlmaLinux 9.8 |
| Virtualmin version | Virtualmin 8.1 |

There appears to be a bug in Virtualmin 8.1 scheduled backups when using an SFTP destination. Old backups are not being deleted because the configured path is being duplicated.

In **Destination and Format** , the **File on Server** field is configured as:

`01/backup-%Y-%m-%d.tar.gz`

However, when the scheduled backup runs and attempts to delete old backups, it looks for them at:

`01/01/backup-%Y-%m-%d.tar.gz`

The `01` directory is being prepended a second time, causing Virtualmin to search in a non-existent path. As a result, it old backups are not deleted.

The backup itself is created successfully; the issue only affects the deletion of older backups because of the duplicated directory in the path.

---

<div class="post-metadata">

**Author:** ![charisvaltzis](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/c/f9ae1b/32.png) [@charisvaltzis](https://forum.virtualmin.com/u/charisvaltzis)\
**Post date:** [July 18, 2026, 2:08pm UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548/2 "2026-07-18T14:08:02Z")

</div>

Hi,

I ran into exactly the same issue on my server and spent some time debugging it with chatgpt. I think I managed to narrow down the cause.

My environment:

- Virtualmin GPL 8.1.0
- Ubuntu 24.04
- Hetzner Storage Box (SFTP, port 23)

My destination is configured as:

```auto
daily/%Y-%m-%d

```

The backups themselves are created correctly under:

```auto
daily/2026-07-18
daily/2026-07-17
...

```

However, during the purge step the log shows:

```auto
Deleting backups from dailydaily...
Deleting file daily/daily/2026-07-18 via SSH...

```

I also noticed something interesting. When connecting directly with the standard OpenSSH SFTP client and running:

```auto
ls -l daily

```

Hetzner returns:

```auto
daily/2026-07-12
daily/2026-07-13
...

```

instead of only the directory names:

```auto
2026-07-12
2026-07-13

```

It looks like Virtualmin prepends the base directory again during the purge, which results in paths like:

```auto
daily/daily/2026-07-18

```

instead of:

```auto
daily/2026-07-18

```

As a temporary workaround, I wrote a small cleanup script using `lftp` to enforce my retention policy until this is fixed.

Hopefully this helps identify the issue. If you need any additional logs or testing, I’d be happy to help.

---

<div class="post-metadata">

**Author:** ![Le\_Gallois](https://cdn.forum.virtualmin.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@Le\_Gallois](https://forum.virtualmin.com/u/Le_Gallois)\
**Post date:** [July 18, 2026, 2:56pm UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548/3 "2026-07-18T14:56:29Z")

</div>

My thought on this on another similar post was a new server pulling from old stored different server backups, not a big issue for me so I ignored it. The error return intrigued me at the time though.  
Paths seemed correct.  
Hetzner here then and still.

David

---

<div class="post-metadata">

**Author:** ![janderk](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/janderk/32/19320_2.png) [@janderk](https://forum.virtualmin.com/u/janderk)\
**Post date:** [August 5, 2026, 8:46am UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548/4 "2026-08-05T08:46:02Z")

</div>

I can confirm the bug with SFTP

```auto
Deleting backups from backupbackup/cloud12 on SFTP server xxxxxxx.your-storagebox.de matching .*-.*-.* older than 5 days ..
    Deleting file backup/cloud12/2026-07-29 via SSH, which is 6 days old ..
    .. deleted 44 bytes 

```

notice the double “backupbackup”, which should be just “backup”.

Works fine with FTP but I really dont want to use that anymore.

---

<div class="post-metadata">

**Author:** ![janderk](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/janderk/32/19320_2.png) [@janderk](https://forum.virtualmin.com/u/janderk)\
**Post date:** [August 6, 2026, 8:35am UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548/5 "2026-08-06T08:35:15Z")

</div>

I have reported this bug to the [issues tracker on github](https://github.com/virtualmin/virtualmin-gpl/issues/1262)

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [October 5, 2026, 8:36am UTC](https://forum.virtualmin.com/t/old-sftp-backups-are-not-deleted-because-destination-directory-is-duplicated/137548/6 "2026-10-05T08:36:07Z")

</div>

Closed on October 5, 2026, 8:36am UTC

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