rclone: rclone copy --metadata not working for folders
The associated forum post URL from https://forum.rclone.org
What is the problem you are having with rclone?
I did sudo rclone copy --metadata <src> <dest> as root user
To validate the dest content, I did the restore using same rclone cmdline interchanging src and dest as root user.
While the files get the right attributes (permission level, owner, group), the folder has got root:root and restore date.
What is your rclone version (output from rclone version)
rclone v1.61.1
- os/version: oracle 7.9 (64 bit)
- os/kernel: 5.4.17-2136.314.6.2.el7uek.x86_64 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.19.4
- go/linking: static
- go/tags: none
Which OS you are using and how many bits (e.g. Windows 7, 64 bit)
Oracle Linux Server release 7.9
Which cloud storage system are you using? (e.g. Google Drive)
Oracle Cloud Infrastructure
The command you were trying to run (e.g. rclone copy /tmp remote:tmp)
sudo rclone copy --metadata <src> <dest>
A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)
How to use GitHub
- Please use the đ reaction to show that you are affected by the same issue.
- Please donât comment if you have no relevant information to add. Itâs just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 12
- Comments: 38 (15 by maintainers)
Commits related to this issue
- sync: implement directory sync FIXME WIP - needs tests - see FIXMEs This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync FIXME WIP - see FIXMEs This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync FIXME WIP - see FIXMEs This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync FIXME WIP - see FIXMEs This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync FIXME WIP - see FIXMEs This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync FIXME WIP - see FIXMEs This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync This updates the bisync golden tests also which were affected by --dry-run setting of directory modtimes. Fixes #6685 — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync for mod times and metadata Directory mod times are synced by default if the backend is capable and directory metadata is synced if the --metadata flag is provided and t... — committed to rclone/rclone by ncw 3 years ago
- sync: implement directory sync for mod times and metadata Directory mod times are synced by default if the backend is capable and directory metadata is synced if the --metadata flag is provided and t... — committed to Fornaxian/rclone by ncw 3 years ago
Iâm willing to pledge $100 for full metadata preservation*. Unfortunately I donât have the clout to get my employer to sponsor it (I donât think they use rclone). @ncw do you use something like Bountysource?
* by full metadata what I mean is that
should have the exact same result as
where A and B are both linux systems.
I would also accept non-preservation of hardlinks (i.e., rsync without the
-Hoption). But directory mtime and permissions are a must!This is for my own usage. Unfortunately Iâm not a rich man, have zero Golang experience and not much free time. If there is some sort of crowdfunding/bounty setup Iâd be willing to chip in up to say $200.
I have made a first pass at making sync preserve the folder modtimes/metadata here:
v1.66.0-beta.7695.b8c0d3318.fix-6685-dir-sync on branch fix-6685-dir-sync
This is an early beta for comments and testing. It is missing a lot of integration tests so may not work properly!
It has some of your commits in @nielash - thank you! - I re-used them for setting directory modtimes. I renamed the method to
DirSetModTimewhich is not as nice asTouchDirbut is consistent with the other methods and doesnât imply directory creation. Note that it also updates some bisync golden tests in b8c0d3318e9a4137dc8991904dbc3b31ce2be56b in a very minor way.Here are some notes on how it works and what needs to be done. It also describes how to update a backend to support Directory modtimes or to support Metadata on directories.
Notes
A non metdata sync will sync directory modtimes. This is a change from the existing code but I think it will be welcomed by users. The reads directory ModTime and sets them using DirSetModTime if available (or Directory.SetModTime).
A
--metadatasync will read directory metadata (including mod times) using Metadata and set them with SetMetadataSyncs with and without metadata may have an additional pass afterwards to SetModTimes of directories if they change when files are added (the
DirModTimeUpdatesOnWritefeature flag).FIXME directory wrapping these backends needs fixing to proxy to underlying Directory
They all just need to override the path in the Directory so maybe a generic class to do that is needed.
FIXME need to kill off NewDirCopy - in use by crypt and is wrong - need to make Directory wrapper and proxy everything else to the underlying Directory
TODO
fstests
WriteDirModtimethen it must allow directories to be created with metadata (MkdirMetadata).WriteDirSetModTimethen it must allow directories to be created with modtime (MkdirMetadata).To add directory metadata to a backend
Decide on feature flags
Make
ListandListRreturn specialized directory objects satisfying these interfacesRemember assertions.
Implement the optional method
MkdirMetadata. This should create a directory with the metadata given. At minimum the backend should interpret themtimemetadata to set the modification time.It can implement
DirSetModTimetoo but (I think!) rclone will work without it.SetModTime only
If a backend can only set modtime on directories and doesnât have directory metadata
This does not need to make
List/ListRreturn specialized directory objects. Instead it should implement aDirSetModTimeoptional method.This is a much simpler integration.
The Date Modified for the folders working for rmount+winfsp (Windows) on the S3 compatible object store layer work correctly in this new version?
I performed tests with the version rclone-v1.67.0-beta.7845.71069ed5c and rclone-v1.66.0-beta.7732.f5f86786b.fix-6685-dir-sync for Windows and after the expiration of the cache time, the date of all folders is changed to 31/12/1999 - The date of files is still correct.
Use this command to mount the driver:
rclone mount oci:/rclone-lab Z: --config "C:\Users\Administrator.LAB\AppData\Roaming\rclone\rclone.conf" --vfs-cache-mode writes -o FileSecurity="D:P(A;;FRFW;;;WD)" -o FileSecurity="D:P(A;;FRFWFX;;;WD)" -o FileSecurity="D:P(A;;FA;;;WD)"Source:
Destination:
I used the following timing commands:
Then, the time of the folders is updated correctly, but after the cache time expires, they return to 31/12/1999. Same erro with:
# rclone bisync . Z: --create-empty-src-dirs --compare size,modtime,checksum --slow-hash-sync-only --resilient -MvP --fix-case --resync# rclone sync -vP --metadata-mapper --metadata --refresh-times . Z:Any news on this?
Iâm currently thinking about metadata for directories.
The problem with this idea is that directories donât support
SetModTimeat the moment. This is something which will need to be added to backends to support it.That is my ultimate plan đ
It is a very useful thing. However it is not at all a straight forward bit of work since the assumption that rclone can create and destroy directories whenever it wants is baked into every backend.
Some backends will need the modtime of directories updating if you write files in them, but I imagine some wonât.
I had a quick thought about this. Would it be of interest if I could write a small command that copies dir modtimes from one remote to another (for backends that support it)? It would be intended as more of a short-term stop-gap to tide us over while we wait hopefully for full dir metadata support, which would be a much more complicated project.
Many backends (including
localanddrive) already support listing directory modtime, like:So the command Iâm imagining would do basically the equivalent of the above command, then loop through all the results and do something like
err = dir.SetModTime(ctx, t)for each corresponding dir on the dest. (Probably with a--modify-windowcheck first, and maybe also support for--update.)An alternate approach might be to tack it on to the end of
copy/syncas an optional extra step, very much like--create-empty-src-dirs.My use case is that my Google Drive currently has all the correct modtimes of my folders, and when I use rclone to
syncthem to a new computer, I want to be able to follow that with a command to copy over all the folder modtimes fromdrivetolocal. Modtime is the main piece of dir metadata I care about (especially because of macOS âpackagesâ which are really dirs), so in my opinion, a command like this would deliver a lot of value for relatively little effort.Is this something youâd want?
Yes, we are a company, but for now we are evaluating whether the solution meets our clientâs requirements. In initial tests, we are achieving very encouraging results.
Letâs consider paid support for our end customer. Thanks for help.
@danieldemoraisgurgel
If you add
directory_markers = trueto your configThen directories will have a persistent date - otherwise they donât actually exist.
I donât think syncing directory modification times or metadata will work with
directory_markersyet though. If youâd like to see this please open a new issue about it. If you are working on behalf of a company you might be interested in taking out a support contract and we could add that as part of it.Just realizing I never responded to this part â yes, I think we should do that. It will keep us honest and give us the confidence to finally graduate bisync from
beta.And I agree about waiting until after the v1.66 release, as I fully expect all kinds of backend-specific oddities to appear! (My guess is most of them will be problems with the tests as opposed to the actual code being tested, but I could be wrong!)
Thanks for the notes @nielash . Iâll incorporate the feedback into the next revision when Iâm back at my desk tomorrow (currently on a bus somewhere in France!). Iâll reply in detail then too.
WOW this is so exciting! It looks awesome. Canât wait to take it for a test drive! đ đ
Wow, great work @nielash ! Iâve been wanting this functionality for so long and it appears that youâve implemented support for it in a way that will work for me. Iâm going to build your fork and give it a try but just from a cursory glance at the source, it looks like it will do exactly what I want. Thanks for sharing this!
Iâm added simple example add metadata for local backend https://github.com/rclone/rclone/compare/master...lxShaDoWxl:rclone:master
Yes, but not for folders, so in the example above rclone and rsync would give different outputs.