Cant get rclone to mirror

Good day everyone,

I am trying to make an automated rclone backup of my server using Murena cloud. I however cannot get the script to work. I do know that rclone does work since the Devices folder from murena cloud is nicely backed up to my raid1 drive. I however get errors when I try to mirror my local raid 1 murena folder back to murena cloud. Please see the description below.

My situation is as follows:

  1. (THIS WORKS) The base of my data is on a 4 TB raid 1 drive. Here I have 2 folders, one being my base of murena drive and the other my immich photo library.
    1.1) On my phone I’ve set up the immich app to upload the photos to my immich instance on my raid 1 drive and I’ve set up the nextcloud app to upload the photos to my Photos/Camera folder in the murena folder on my raid 1 drive.
    1.2) My murena drive mostly contains my documents, music and photos.
    1.3) My immich folder also contains all my photos from the murena drive but this time with the manipulation of immich with facial recognition. I’d like to have a duplicate photo library since i dont want my photos to be able to get corrupted from immich since it’s still in beta.

  2. (THIS DOES NOT WORK) Every night I want to sync these folders to a second raid 0 drive and to murena cloud. I’ve set up rclone using this guide.
    2.1) First I want to sync to my raid 0 drive. I prefer this before syncing to murena since this builds in a safeguard that if murena causes any corruption i still have a valid backup. I have written the following script to backup my murena folder, the script also backs up any changes for 7 days. Please feel free to also point out any problems in my code if you like, I’m an mechanical engineer by profession and not a software engineer. I’m planning to trigger this script every morning at 4 am using cron.

~/Headless$ cat backup_murena_external.sh
#!/bin/bash

# Source and Destination folders
SOURCE="/home/USERNAME/externalRAID/Murena"
DESTINATION="/home/USERNAME/external2/Backup/Murena"
BACKUP_OLD="/home/USERNAME/external2/Backup/Murena_recently_deleted"

# Number of daily backups to keep
DAYS_TO_KEEP=7

# Get the current date in YYYY-MM-DD format
DATE=$(date +%Y-%m-%d)

# Function to create the daily backup directory if it doesn't exist
create_backup_dir() {
  if [ ! -d "$BACKUP_OLD/$1" ]; then
    mkdir -p "$BACKUP_OLD/$1"
    echo "Created backup directory: $BACKUP_OLD/$1"
  fi
}

# Check if the destination folder exists
if [ ! -d "$DESTINATION" ]; then
  echo "Error: Destination folder '$DESTINATION' does not exist."
  exit 1
fi

# Check if the backup old folder exists
if [ ! -d "$BACKUP_OLD" ]; then
  mkdir -p "$BACKUP_OLD"
  echo "Created backup directory for old files: $BACKUP_OLD"
fi

# Iterate through files in the source folder
find "$SOURCE" -type f -print0 | while IFS= read -r -d $'\0' source_file; do
  # Get the relative path of the source file from the source folder
  relative_path=$(echo "$source_file" | sed "s|^$SOURCE/||")

  # Construct the full path of the corresponding file in the destination folder
  destination_file="$DESTINATION/$relative_path"

  # Check if the destination file exists
  if [ -e "$destination_file" ]; then
    # Create the daily backup directory if it doesn't exist
    create_backup_dir "$DATE"

    # Construct the backup path for the old file
    backup_file="$BACKUP_OLD/$DATE/$relative_path"
    backup_dir=$(dirname "$backup_file")

    # Create the necessary subdirectories in the backup folder
    mkdir -p "$backup_dir"

    # Move the existing file in the destination to the backup folder
    mv "$destination_file" "$backup_file"
    echo "Moved existing file to backup: $destination_file -> $backup_file"
  fi
done

# Perform the rsync operation
rsync -av --delete "$SOURCE/" "$DESTINATION/"

echo "Rsync backup completed."

# --- Optional: Cleanup old daily backups ---
find "$BACKUP_OLD" -maxdepth 1 -type d -ctime +"$DAYS_TO_KEEP" -exec rm -rf {} \;
echo "Cleaned up backups older than $DAYS_TO_KEEP days (if any)."

exit 0

2.2) I also want to perform a backup to murena cloud after the above script is completed. The idea is that i first mirror the Devices folder from murena cloud to my raid 1 drive and then mirror the murena folder on my raid 1 drive back to murena cloud, excluding the Devices folder.

I however cannot get the script to work. I do know that rclone does work since the Devices folder from murena cloud is nicely backed up to my raid1 drive. I however get errors when I try to mirror my local raid 1 murena folder back to murena cloud.

This is my current script:

~/Headless$ cat backup_murena_cloud.sh
#!/bin/bash
echo "START CLOUD BACKUP MURENA"
echo "$(date +'%d-%m-%Y %H:%M')"
echo "Running as user: $(whoami)"
echo "Primary group: $(id -gn)"
echo "All groups: $(id -Gn)"
# ====== CONFIGURATION ======

# Toggle for dry run mode (true or false)
DRY_RUN=true

# Rclone remote name
remote_name="murena"

# Local base Murena folder
local_base="/externalRAID/Murena"
local_devices="$local_base/Devices"

# Log file
logfile=/home/USERNAME/Desktop/sync_murena.log

# ====== FUNCTIONAL LOGIC ======

# Set dry-run flag
dry_flag=""
if [ "$DRY_RUN" = true ]; then
    dry_flag="--dry-run"
    echo "Dry-run mode enabled." >> "$logfile"
fi

echo "========== SYNC STARTED: $(date) ==========" >> "$logfile"

# Step 1: Sync Devices from remote to local
echo "Step 1: Syncing Devices from remote to local..." >> "$logfile"
rclone sync "$remote_name:Devices" "$local_devices" \
    $dry_flag --delete-excluded --progress -vv >> "$logfile" 2>&1

# Step 2: Sync all other folders from local to remote, excluding Devices
echo "Step 2: Syncing all other folders (excluding Devices) to remote..." >> "$logfile"
rclone sync "$local_base" "$remote_name:" \
    --exclude "Devices/**" \
    $dry_flag --progress -vv >> "$logfile" 2>&1

echo "========== SYNC COMPLETED: $(date) ==========" >> "$logfile"

My log has the following output:

~/Headless$ cat ~/Desktop/sync*
Dry-run mode enabled.
========== SYNC STARTED: wo 16 apr 2025  0:16:57 CEST ==========
Step 1: Syncing Devices from remote to local...
2025/04/16 00:16:59 DEBUG : rclone: Version "v1.69.1" starting with parameters ["/snap/rclone/528/bin/rclone" "sync" "murena:Devices" "/externalRAID/Murena/Devices" "--dry-run" "--delete-excluded" "--progress" "-vv"]
2025/04/16 00:16:59 DEBUG : Creating backend with remote "murena:Devices"
2025/04/16 00:16:59 DEBUG : Using config file from "/home/USERNAME/snap/rclone/528/.config/rclone/rclone.conf"
2025/04/16 00:16:59 DEBUG : found headers: 
2025/04/16 00:16:59 DEBUG : Chunks temporary upload directory: https://murena.io/remote.php/dav/uploads/USERNAME2/
2025/04/16 00:16:59 DEBUG : Creating backend with remote "/externalRAID/Murena/Devices"

2025/04/16 00:16:59 DEBUG : Added delayed dir = "Fairphone_FP5_42708826", newDst=<nil>
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.1s
2025/04/16 00:16:59 DEBUG : Added delayed dir = "Fairphone_FP5_42708826/rom_settings", newDst=<nil>
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.2s
2025/04/16 00:17:00 DEBUG : Added delayed dir = "Fairphone_FP5_42708826/rom_settings/app_list", newDst=<nil>
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.3sTransferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.4s
2025/04/16 00:17:00 DEBUG : Fairphone_FP5_42708826/rom_settings/app_list/packages_list.csv: Need to transfer - File not found at Destination
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.5s
2025/04/16 00:17:00 NOTICE: Fairphone_FP5_42708826/rom_settings/app_list/packages_list.csv: Skipped copy as --dry-run is set (size 9.298Ki)
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Transferred:            0 / 1, 0%
Elapsed time:         0.5s
Transferring:
 * Fairphone_FP5_42708826…list/packages_list.csv: transferring
2025/04/16 00:17:00 DEBUG : Local file system at /externalRAID/Murena/Devices: Waiting for checks to finish
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s
2025/04/16 00:17:00 DEBUG : Local file system at /externalRAID/Murena/Devices: Waiting for transfers to finish
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s
2025/04/16 00:17:00 DEBUG : Waiting for deletions to finish
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s
2025/04/16 00:17:00 NOTICE: Fairphone_FP5_42708826/rom_settings/app_list: Skipped set directory modification time as --dry-run is set
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s
2025/04/16 00:17:00 NOTICE: Fairphone_FP5_42708826/rom_settings: Skipped set directory modification time as --dry-run is set
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s
2025/04/16 00:17:00 NOTICE: Fairphone_FP5_42708826: Skipped set directory modification time as --dry-run is set
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5sTransferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s
2025/04/16 00:17:00 NOTICE: 
Transferred:   	    9.298 KiB / 9.298 KiB, 100%, 0 B/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         0.5s

2025/04/16 00:17:00 DEBUG : 6 go routines active
Step 2: Syncing all other folders (excluding Devices) to remote...
2025/04/16 00:17:00 DEBUG : rclone: Version "v1.69.1" starting with parameters ["/snap/rclone/528/bin/rclone" "sync" "/externalRAID/Murena" "murena:" "--exclude" "Devices/**" "--dry-run" "--progress" "-vv"]
2025/04/16 00:17:00 DEBUG : Creating backend with remote "/externalRAID/Murena"
2025/04/16 00:17:00 DEBUG : Using config file from "/home/USER/snap/rclone/528/.config/rclone/rclone.conf"
2025/04/16 00:17:00 DEBUG : Creating backend with remote "murena:"
2025/04/16 00:17:00 DEBUG : found headers: 
2025/04/16 00:17:00 DEBUG : Chunks temporary upload directory: https://murena.io/remote.php/dav/uploads/USERNAME2/

2025/04/16 00:17:00 DEBUG : Devices: Excluded
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.2s
2025/04/16 00:17:00 ERROR : Local file system at /externalRAID/Murena: error reading source root directory: directory not found
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.2s
2025/04/16 00:17:00 DEBUG : webdav root '': Waiting for checks to finish
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.2s
2025/04/16 00:17:00 DEBUG : webdav root '': Waiting for transfers to finish
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.2s
2025/04/16 00:17:00 ERROR : webdav root '': not deleting files as there were IO errors
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.2s
2025/04/16 00:17:00 ERROR : webdav root '': not deleting directories as there were IO errors
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.2s
2025/04/16 00:17:00 ERROR : Attempt 1/3 failed with 1 errors and: directory not found
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.2s
2025/04/16 00:17:00 DEBUG : Devices: Excluded
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.3s
2025/04/16 00:17:00 ERROR : Local file system at /externalRAID/Murena: error reading source root directory: directory not found
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.3s
2025/04/16 00:17:00 DEBUG : webdav root '': Waiting for checks to finish
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.3s
2025/04/16 00:17:00 DEBUG : webdav root '': Waiting for transfers to finish
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.3s
2025/04/16 00:17:00 ERROR : webdav root '': not deleting files as there were IO errors
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.3s
2025/04/16 00:17:00 ERROR : webdav root '': not deleting directories as there were IO errors
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.3s
2025/04/16 00:17:00 ERROR : Attempt 2/3 failed with 1 errors and: directory not found
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.3sTransferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.5s
2025/04/16 00:17:00 DEBUG : Devices: Excluded
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.5s
2025/04/16 00:17:00 ERROR : Local file system at /externalRAID/Murena: error reading source root directory: directory not found
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.5s
2025/04/16 00:17:00 DEBUG : webdav root '': Waiting for checks to finish
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5s
2025/04/16 00:17:00 DEBUG : webdav root '': Waiting for transfers to finish
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5s
2025/04/16 00:17:00 ERROR : webdav root '': not deleting files as there were IO errors
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5s
2025/04/16 00:17:00 ERROR : webdav root '': not deleting directories as there were IO errors
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5s
2025/04/16 00:17:00 ERROR : Attempt 3/3 failed with 1 errors and: directory not found
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5sTransferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5s
2025/04/16 00:17:00 NOTICE: 
Transferred:   	          0 B / 0 B, -, 0 B/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.5s

2025/04/16 00:17:00 DEBUG : 4 go routines active
2025/04/16 00:17:00 NOTICE: Failed to sync: directory not found
========== SYNC COMPLETED: wo 16 apr 2025  0:17:00 CEST ==========

Can someone please help me set this up? And possibly point out any caviats I’m missing in my code because I’m not an experienced coder?

This is my system info:

cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Thank you in advance.

Johan

Hello Johan, welcome to the community. This is specifically concerning rclone and murena.io. To be honest I do not know either.

But I would start trying to resolve the first error in your log:

Is the relative path /externalRAID/Murena sufficient for rclone? Does it look in home folder for this? Or does it need full paths like /home/USERNAME/externalRAID/Murena? Just a first guess …

Good day!

Thank you for the reply! I’ve tried both the relative and the absolute path of the mountpoints.

The location is correct. It is a mounted external raid1 drive. It is mounted to:

Location: /externalRAID

drwxr-xr-x   7 USERNAME USERNAME  4096 apr 13 14:04 externalRAID

Location: ~/externalRAID

lrwxrwxrwx  1 USERNAME USERNAME    13 apr  6 00:27 externalRAID -> /externalRAID

And the connected drives:

lsblk
sdc    8:32   0   3,6T  0 disk 
└─sdc1
       8:33   0   3,6T  0 part /externalRAID

Ans the contents of the folder:

/externalRAID$ ls -l
total 28
drwxrwxr-x  3 USERNAME USERNAME  4096 apr  8 15:34 Backup_Music
drwxrwxr-x  8 USERNAME USERNAME  4096 apr 15 15:08 Immich
drwx------  2 root   root   16384 apr  6 00:03 lost+found
drwxrwxr-x 10 USERNAME USERNAME  4096 apr 15 21:25 Murena

Another guess:

In help for rclone the command without other options is
rclone sync SOURCE remote:DESTINATION

In your Step 1 remote:DESTINATION is murena:Devices - this seems to work so far.

In Step 2
Your SOURCE is ā€œ/externalRAID/Murenaā€ - folder exists, should work.
Your remote:DESTINATION is ā€œmurena:ā€ - perhaps this needs a destination part (maybe a simple / would work)

I just realized that you are using rclone as snap. Snaps work in some kind of sandbox. Most snaps are not allowed to access files and folders outside of home folder (this applies also to links in home folder). In home folder most snaps have no access to hidden files and folders, too.

To verify this you can create a folder in your home folder and try to sync that.

1 Like

The snap (no snap) will not follow symlinks since apparmor can not verify the security of the target…

If you either switch from symlinking to bind-mounting or alternatively mount your external raid under /mnt or /media and connect the removable-media interface of the rclone snap it should work well…

3 Likes

ahhhh well that makes sense! I was pulling my hairs out. I guess this is my first interaction where I’m part of team ā€˜snap bad’ then haha.

I do see the security implications tough.

Thank you!

This fixed it! Thank you!

3 Likes

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