Preservation Of Permissions with Copy/Sync

Currently when copying or syncing files with Rclone, it does not preserve the permissions of those files. How would I be able to preserve the permissions of the file through a copy/sync operations?

You'd have to expand on what you mean, what cloud remote, etc.

Generally, cloud remotes have no concept of permissions so it is not applicable.

I am currently copying a file from on-premise to an AWS S3 Bucket and then copy that file to a VPC.

So let's say file A has read only permissions, when copying file A from on-premise to the S3 bucket and then to the VPC, the file's permissions become read and write. So essentially when the file is copied over, its permissions are not preserved from the source file.

This is something I’d like to see for my use case.
I use dietpi and the backup process is rsync based to a NAS via NFS. I then use rclone to back this up to Backblaze B2 and although it copy’s symlinks it doesn’t copy ownership and permissions. Without this you cannot get working restore process.
I have to tarball it and then sync that instead. No big issue, but if I could do it in one that would remove a step from the process.

Cloud remotes generally have no concept of Linux permissions so it's nothing to copy as it's unique to Linux.

What's the VPC in your syntax there?

I do know tar'ing the file and then copying/syncing it to in-cloud VPC helps to preserve the permissions; however, one of the issues is that it slows down the performance of the operation because of the tar operation.

If there is any other way around it, I would be interested to figure it out.

Just an instance on the cloud like an AWS EC2 instance.

Any reference to the underneath code which we can modify or update

The only reason I thought this a possible feature is that symlinks can be preserved today and that the same way to use a metadata file that preserves the symlink could hold permissions also.

This is what the relatively new --metadata or -M flag is for. You need both the backends to support it, but luckily both S3 and local do.

Do you should find if you use the -M flag rclone writes extra metadata with the permissions on the objects and it reads them back when you copy them back again.

2 Likes

Thank you. I tried out the --metadata flag and it was able to preserve the permissions of files when copying from on-prem to cloud and back to on-prem. However, when I was testing on my folders, I noticed that the permissions of the folders were not preserved and were set back to the default folder permissions of the file system.

Is there any way I could get my permissions for my folder preserved as well when copying or syncing?

@ncw I second that. I tried out -M flag today and it preserves for files but not folders. This causes issues when syncing files to NAS that may have ACL's set as when they copy back user may no longer have perms to see files/folders.

1 Like

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