1

I'm trying to copy a folder using rsync

rsync -avP "$src_path" "$target_path"

But rsync is giving me this error.

rsync: recv_generator: mkdir $target_path/sub_dir failed: Read-only file system (30)
*** Skipping any contents from this failed directory ***

Here src_path is a read-only directory but the target_path is writable.

I can easily do the copy using cp but rsync fails.

Cyber Avater
  • 153
  • 2
  • 8
  • Did you try with elevated permissions, sudo rsync ... ? – sudodus Sep 29 '21 at 07:00
  • It doesn't matter, I won't have write permission for the source because the files are not owned by me it's a google drive folder to which I have only view access. – Cyber Avater Sep 29 '21 at 07:20
  • Instead of writing files, you can try to create a tarball, You may need elevated permissions (prefix with sudo) to preserve the ownership and permissions, tar -cvzf file.tar.gz "$src_path" ; Read more about tar in man tar or find a tutorial via the internet. – sudodus Sep 29 '21 at 07:30
  • cp (cp -r -L) -> works

    tar (tar -cvzf file.tar.gz "$src_path") -> works

    rsync (rsync -avP "$src_path" "$target_path") -> doesn't work (it'll only work if I have write access for src_path)

    I need rsync (I already stated that I can copy it using cp (now also tar, tested)) but want rsync

    – Cyber Avater Sep 29 '21 at 07:42
  • 1
    An alternative is to turn off the archive option -a and let rsync write with the default ownership/permissions of the target directory, (e.g. replace -a with -r). By the way, what file system is it (where your target directory is located)? A linux filesystem (e.g. ext4) or maybe a Windows or MacOS file system? – sudodus Sep 29 '21 at 07:43
  • rsync -rl "$src_path" "$target_path" also doesn't work. linux filesystem (from google colab) – Cyber Avater Sep 29 '21 at 07:45
  • 1
    It is important here to give specific information on the nature of your source and target file system, and the version of rsync. I cannot reproduce this issue with rsync version 3.2.3 protocol version 31 on Ubuntu 21.04 copying from and to an ext4 partition. – vanadium Sep 29 '21 at 07:57
  • I've added reproduction steps. – Cyber Avater Sep 29 '21 at 08:43
  • I might have completely misunderstood, but the error message suggests to me that rsync is failing because it can’t make a directory in the target as it’s read only. I’m sure you’re right - rsync with those options shouldn’t need the source to be read/write. This might be too basic, but have you checked the absolute path to the target is correct, ie that you’re not using a relative path and therefore trying to create a directory in the source (read only) directory? – Will Sep 29 '21 at 10:31
  • I'm using Absolute path. You can follow the reproduction steps and verify if you want. – Cyber Avater Sep 29 '21 at 17:43

1 Answers1

1

TLDR: The issue is caused by the old version of rsync (here in my case 3.1.2). Just update it to the latest version and that should solve the problem.

The known tested version that has this issue fixed is 3.2.3.

If you can't install the latest version on older ubuntu, follow here Install latest version of rsync (3.2.3) on ubuntu 18.04

Old, just kept as a reference:

It turns out that, this is a bug of rsync which was fixed in later versions.

The version provided by google collab is 3.1.2 (buggy), while the latest version is 3.2.3 (which has the issue fixed).

!apt update && apt upgrade -y doesn't upgrade rsync to 3.2.3.

Not recommended, follow the method provided above

I needed to manually download and install from here. (And yes, I also had to download and update all the listed dependencies manually the same way).

Cyber Avater
  • 153
  • 2
  • 8
  • I'm on ubuntu 20.04 and after running sudo update and upgrade I still have version 3.1.2. Do I need to do some manual installation also on 20.04? – Kvothe Dec 05 '22 at 16:42
  • @Kvothe I'm not sure, but your first bet should be following this one (https://askubuntu.com/q/1389729/1094129) as it's more easier than manually installing all.

    This should be enough, but if no luck, download the latest rsync .deb file for Ubuntu 22.04 LTS (Jammy Jellyfish) and install it using gdebi (it'll list dependencies that you in to manually install/update like this one.)

    – Cyber Avater Dec 08 '22 at 04:29