Empty folders not deleted, 'rm' command errors and occasional deletion of folders with files during backups

What is the problem you are having with rclone?

Empty folders in the mounted location and empty folders in the cloud. The "rm" command does not delete empty folders (displays errors).
Sometimes in the cloud there is a deletion of all folders containing files (also except for 5 backups, which should be intact) - this is also an error.
For my main purpose, I use rclone as a cloud for backing up important files. The file to be backed up is run in a cron command every so often. The script is designed to save 2 folders with backups, which include folders with backup dates. The script then deletes the oldest folders so that the most recent copies (currently the last 5) are still maintained in the folder.
Also, I am very much asking for small help to improve my backup script and to solve the problem with empty folders.

The content of the code of my backup script (the script works fully without errors, when the data is saved to disk, not the mounted cloud):

#!/bin/bash

# ... backup code ...

# Remove redundant folders in the InfluxDB & Grafana directory
cd '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB' && sudo ls -tr | head -n -5 | xargs --no-run-if-empty rm -r
cd '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana' && sudo ls -tr | head -n -5 | xargs --no-run-if-empty rm -r

# Change the permissions of the folder with the backup
sudo chmod -R 777 '/!Mega_cloud/Kopia wa┼╝nych danych VPS'

Run the command 'rclone version' and share the full output of the command.

ubuntu@losalamosvps:/$ rclone version
rclone v1.65.2
- os/version: ubuntu 22.04 (64 bit)
- os/kernel: 5.15.0-1049-oracle (aarch64)
- os/type: linux
- os/arch: arm64 (ARMv8 compatible)
- go/version: go1.21.6
- go/linking: static
- go/tags: none

Which cloud storage system are you using? (eg Google Drive)

Mega cloud (https://mega.io/)

The command you were trying to run (eg rclone copy /tmp remote:tmp)

I use rclone as a systemd service file:

[Unit]
Description=Rclone Mega Mount Service
After=network-online.target

[Service]
Type=notify
ExecStart=/usr/bin/rclone mount Mega: /!Mega_cloud/ --vfs-cache-mode writes --allow-other --allow-non-empty --log-level INFO --log-file /tmp/rclone.log
ExecStop=/bin/fusermount -uz /!Mega_cloud/
Restart=on-success
RestartSec=5
User=root
Group=root

[Install]
WantedBy=default.target

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

ubuntu@losalamosvps:/$ rclone config redacted
2024/02/02 09:18:05 Failed to load config file "/home/ubuntu/.rclone.conf": open /home/ubuntu/.rclone.conf: permission denied
ubuntu@losalamosvps:/$ sudo rclone config redacted
[Mega]
type = mega
user = XXX
pass = XXX
hard_delete = true
### Double check the config for sensitive info before posting publicly

A log from the command that you were trying to run with the -vv flag

I paste the logs from log file using --log-level INFO --log-file /tmp/rclone.log. Is it sufficient? The log file is added as link (new users can not upload files).
LINK

I will also post my screenshots and logs below to better show the problem

  • Errors reported by my backup script:
rm: cannot remove 'backup_2024-02-01_13-10/20240201T121002Z.6.tar.gz': Input/output error
rm: cannot remove 'backup_2024-02-01_13-10/20240201T121002Z.bolt.gz': Input/output error
rm: cannot remove 'backup_2024-02-01_13-10/20240201T121002Z.manifest': Input/output error
rm: cannot remove 'backup_2024-02-01_13-10/20240201T121002Z.sqlite.gz': Input/output error
rm: cannot remove 'backup_2024-02-01_13-30': Input/output error
rm: cannot remove 'backup_2024-02-01_12-31': Input/output error
rm: cannot remove 'backup_2024-02-01_12-37': Input/output error
rm: cannot remove 'backup_2024-02-01_12-40': Input/output error
rm: cannot remove 'backup_2024-02-01_12-42': Input/output error
rm: cannot remove 'backup_2024-02-01_12-43': Input/output error
rm: cannot remove 'backup_2024-02-01_12-49': Input/output error
rm: cannot remove 'backup_2024-02-01_12-52': Input/output error
rm: cannot remove 'backup_2024-02-01_13-00': Input/output error
rm: cannot remove 'backup_2024-02-01_13-10/grafana.db': Input/output error
rm: cannot remove 'backup_2024-02-01_13-10/grafana.ini': Input/output error
rm: cannot remove 'backup_2024-02-01_13-30': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-31': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-37': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-40': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-42': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-43': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-49': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_12-52': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/Grafana/backup_2024-02-01_13-00': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/backup_2024-02-01_12-31': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/backup_2024-02-01_12-37': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/backup_2024-02-01_12-40': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/backup_2024-02-01_12-42': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/backup_2024-02-01_12-43': Input/output error
chmod: cannot read directory '/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/backup_2024-02-01_12-49': Input/output error

2024/02/02 05:15:55 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "delete" "Mega:/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/" "--rmdirs" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:15:55 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/"
2024/02/02 05:15:55 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:15:56 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/" to be canonical "Mega:!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB"
2024/02/02 05:15:56 ERROR : : error listing: directory not found
2024/02/02 05:15:56 DEBUG : Waiting for deletions to finish
2024/02/02 05:15:56 ERROR : Attempt 1/3 failed with 2 errors and: directory not found
2024/02/02 05:15:56 ERROR : : error listing: directory not found
2024/02/02 05:15:56 DEBUG : Waiting for deletions to finish
2024/02/02 05:15:56 ERROR : Attempt 2/3 failed with 2 errors and: directory not found
2024/02/02 05:15:56 ERROR : : error listing: directory not found
2024/02/02 05:15:56 DEBUG : Waiting for deletions to finish
2024/02/02 05:15:56 ERROR : Attempt 3/3 failed with 2 errors and: directory not found
2024/02/02 05:15:56 DEBUG : 9 go routines active
2024/02/02 05:15:56 Failed to delete with 2 errors: last error was: directory not found
2024/02/02 05:24:42 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "delete" "Mega:/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/*" "--rmdirs" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:24:42 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/*"
2024/02/02 05:24:42 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:24:42 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/*" to be canonical "Mega:!Mega_cloud/Kopia wa┼╝nych danych VPS/InfluxDB/*"
2024/02/02 05:24:42 DEBUG : Waiting for deletions to finish
2024/02/02 05:24:42 ERROR : : error listing: directory not found
2024/02/02 05:24:42 ERROR : Attempt 1/3 failed with 2 errors and: directory not found
2024/02/02 05:24:42 ERROR : : error listing: directory not found
2024/02/02 05:24:42 DEBUG : Waiting for deletions to finish
2024/02/02 05:24:42 ERROR : Attempt 2/3 failed with 2 errors and: directory not found
2024/02/02 05:24:42 ERROR : : error listing: directory not found
2024/02/02 05:24:42 DEBUG : Waiting for deletions to finish
2024/02/02 05:24:42 ERROR : Attempt 3/3 failed with 2 errors and: directory not found
2024/02/02 05:24:42 DEBUG : 10 go routines active
2024/02/02 05:24:42 Failed to delete with 2 errors: last error was: directory not found
2024/02/02 05:25:12 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "delete" "Mega:/!Mega_cloud/" "--rmdirs" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:25:12 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/"
2024/02/02 05:25:12 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:25:13 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/" to be canonical "Mega:!Mega_cloud"
2024/02/02 05:25:13 ERROR : : error listing: directory not found
2024/02/02 05:25:13 DEBUG : Waiting for deletions to finish
2024/02/02 05:25:13 ERROR : Attempt 1/3 failed with 2 errors and: directory not found
2024/02/02 05:25:13 ERROR : : error listing: directory not found
2024/02/02 05:25:13 DEBUG : Waiting for deletions to finish
2024/02/02 05:25:13 ERROR : Attempt 2/3 failed with 2 errors and: directory not found
2024/02/02 05:25:13 ERROR : : error listing: directory not found
2024/02/02 05:25:13 DEBUG : Waiting for deletions to finish
2024/02/02 05:25:13 ERROR : Attempt 3/3 failed with 2 errors and: directory not found
2024/02/02 05:25:13 DEBUG : 11 go routines active
2024/02/02 05:25:13 Failed to delete with 2 errors: last error was: directory not found
2024/02/02 05:26:04 Can't set -q and --log-level
2024/02/02 05:26:23 Can't set -q and --log-level
2024/02/02 05:26:35 Can't set -q and --log-level
2024/02/02 05:26:41 Can't set -q and --log-level
2024/02/02 05:27:29 DEBUG : --min-age 1s to 2024-02-02 05:27:28.302045301 +0000 UTC m=-0.908513746
2024/02/02 05:27:29 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "delete" "Mega:/!Mega_cloud/*" "--min-age" "1s" "--rmdirs" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:27:29 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/*"
2024/02/02 05:27:29 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:27:29 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/*" to be canonical "Mega:!Mega_cloud/*"
2024/02/02 05:27:29 ERROR : : error listing: directory not found
2024/02/02 05:27:29 DEBUG : Waiting for deletions to finish
2024/02/02 05:27:29 ERROR : Attempt 1/3 failed with 2 errors and: directory not found
2024/02/02 05:27:29 ERROR : : error listing: directory not found
2024/02/02 05:27:29 DEBUG : Waiting for deletions to finish
2024/02/02 05:27:29 ERROR : Attempt 2/3 failed with 2 errors and: directory not found
2024/02/02 05:27:29 ERROR : : error listing: directory not found
2024/02/02 05:27:29 DEBUG : Waiting for deletions to finish
2024/02/02 05:27:29 ERROR : Attempt 3/3 failed with 2 errors and: directory not found
2024/02/02 05:27:29 DEBUG : 9 go routines active
2024/02/02 05:27:29 Failed to delete with 2 errors: last error was: directory not found
2024/02/02 05:33:55 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "rmdirs" "Mega:/!Mega_cloud/" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:33:55 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/"
2024/02/02 05:33:55 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:33:56 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/" to be canonical "Mega:!Mega_cloud"
2024/02/02 05:33:56 ERROR : mega root '!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:33:56 DEBUG : removing 1 level 0 directories
2024/02/02 05:33:56 INFO  : mega root '!Mega_cloud': Removing directory
2024/02/02 05:33:56 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:33:56 ERROR : Attempt 1/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:33:56 ERROR : mega root '!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:33:56 DEBUG : removing 1 level 0 directories
2024/02/02 05:33:56 INFO  : mega root '!Mega_cloud': Removing directory
2024/02/02 05:33:56 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:33:56 ERROR : Attempt 2/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:33:56 ERROR : mega root '!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:33:56 DEBUG : removing 1 level 0 directories
2024/02/02 05:33:56 INFO  : mega root '!Mega_cloud': Removing directory
2024/02/02 05:33:56 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:33:56 ERROR : Attempt 3/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:33:56 DEBUG : 11 go routines active
2024/02/02 05:33:56 Failed to rmdirs with 3 errors: last error was: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:00 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "rmdirs" "Mega:/\\!Mega_cloud/" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:35:00 DEBUG : Creating backend with remote "Mega:/\\!Mega_cloud/"
2024/02/02 05:35:00 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:35:01 DEBUG : fs cache: renaming cache item "Mega:/\\!Mega_cloud/" to be canonical "Mega:\\!Mega_cloud"
2024/02/02 05:35:01 ERROR : mega root '\!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:35:01 DEBUG : removing 1 level 0 directories
2024/02/02 05:35:01 INFO  : mega root '\!Mega_cloud': Removing directory
2024/02/02 05:35:01 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:35:01 ERROR : Attempt 1/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:01 ERROR : mega root '\!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:35:01 DEBUG : removing 1 level 0 directories
2024/02/02 05:35:01 INFO  : mega root '\!Mega_cloud': Removing directory
2024/02/02 05:35:01 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:35:01 ERROR : Attempt 2/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:01 ERROR : mega root '\!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:35:01 DEBUG : removing 1 level 0 directories
2024/02/02 05:35:01 INFO  : mega root '\!Mega_cloud': Removing directory
2024/02/02 05:35:01 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:35:01 ERROR : Attempt 3/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:01 DEBUG : 10 go routines active
2024/02/02 05:35:01 Failed to rmdirs with 3 errors: last error was: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:11 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "rmdirs" "Mega:/!Mega_cloud/*" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:35:11 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/*"
2024/02/02 05:35:11 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:35:12 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/*" to be canonical "Mega:!Mega_cloud/*"
2024/02/02 05:35:12 ERROR : mega root '!Mega_cloud/*': Failed to list "": directory not found
2024/02/02 05:35:12 DEBUG : removing 1 level 0 directories
2024/02/02 05:35:12 INFO  : mega root '!Mega_cloud/*': Removing directory
2024/02/02 05:35:12 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:35:12 ERROR : Attempt 1/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:12 ERROR : mega root '!Mega_cloud/*': Failed to list "": directory not found
2024/02/02 05:35:12 DEBUG : removing 1 level 0 directories
2024/02/02 05:35:12 INFO  : mega root '!Mega_cloud/*': Removing directory
2024/02/02 05:35:12 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:35:12 ERROR : Attempt 2/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:12 ERROR : mega root '!Mega_cloud/*': Failed to list "": directory not found
2024/02/02 05:35:12 DEBUG : removing 1 level 0 directories
2024/02/02 05:35:12 INFO  : mega root '!Mega_cloud/*': Removing directory
2024/02/02 05:35:12 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:35:12 ERROR : Attempt 3/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:35:12 DEBUG : 9 go routines active
2024/02/02 05:35:12 Failed to rmdirs with 3 errors: last error was: failed to remove 1 directories: last error: directory not found
2024/02/02 05:37:59 Can't set -q and --log-level
2024/02/02 05:38:10 Can't set -q and --log-level
2024/02/02 05:38:41 DEBUG : --min-age 1s to 2024-02-02 05:38:40.377213902 +0000 UTC m=-0.924067790
2024/02/02 05:38:41 DEBUG : rclone: Version "v1.65.2" starting with parameters ["rclone" "--min-age" "1s" "rmdirs" "Mega:/!Mega_cloud/" "--log-level" "DEBUG" "--log-file" "/rcloneDelete.log"]
2024/02/02 05:38:41 DEBUG : Creating backend with remote "Mega:/!Mega_cloud/"
2024/02/02 05:38:41 DEBUG : Using config file from "/root/.config/rclone/rclone.conf"
2024/02/02 05:38:41 DEBUG : fs cache: renaming cache item "Mega:/!Mega_cloud/" to be canonical "Mega:!Mega_cloud"
2024/02/02 05:38:41 ERROR : mega root '!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:38:41 DEBUG : removing 1 level 0 directories
2024/02/02 05:38:41 INFO  : mega root '!Mega_cloud': Removing directory
2024/02/02 05:38:41 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:38:41 ERROR : Attempt 1/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:38:41 ERROR : mega root '!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:38:41 DEBUG : removing 1 level 0 directories
2024/02/02 05:38:41 INFO  : mega root '!Mega_cloud': Removing directory
2024/02/02 05:38:41 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:38:41 ERROR : Attempt 2/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:38:41 ERROR : mega root '!Mega_cloud': Failed to list "": directory not found
2024/02/02 05:38:41 DEBUG : removing 1 level 0 directories
2024/02/02 05:38:41 INFO  : mega root '!Mega_cloud': Removing directory
2024/02/02 05:38:41 ERROR : : Failed to rmdir: directory not found
2024/02/02 05:38:41 ERROR : Attempt 3/3 failed with 3 errors and: failed to remove 1 directories: last error: directory not found
2024/02/02 05:38:41 DEBUG : 11 go routines active
2024/02/02 05:38:41 Failed to rmdirs with 3 errors: last error was: failed to remove 1 directories: last error: directory not found

  1. Try changing --vfs-cache-mode writes to --vfs-cache-mode full.

  2. Mega support in rclone is slow and not well maintained (so can be buggy). Try using official megacmd client as a webdav server mounted via rclone. You will find many examples on this forum, e.g.:

You were right. I tested Mega cloud mount and Google Drive for a few days and can confirm that Mega behaves incorrectly. Also, when mounting Google Drive cloud, I don't get any errors due to rm and chmod command.

As a curiosity, I will add a graph that shows the space occupied over time. It also shows that the Mega cloud crashes after some time and stops deleting older files completely (so that the cloud keeps growing and does not clean itself automatically). The yellow color is Mega, and the blue color is Google Drive.

I think I will switch to Google Drive completely, as I don't want to have problems with Mega.

1 Like

Some providers are more reliable than others - obviously. Usually you have what you pay for. Gdrive has its problems too.

The major problem is that many people try to use consumer grade services as enterprise solutions:) it will never fly:)

They all have their limitations - but if used within service rules envelope then all is usually ok.

1 Like

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