Wrong timestamp on folders after rsync and files:scan

Nextcloud version (eg, 18.0.2): 20.0.0
Operating system and version (eg, Ubuntu 20.04): Debian 10
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.1): 7.3.19

The issue you are facing:

Hi,
I am experiencing a similar issue as reported here. Basically, scanning the files after a migration, I am able to keep the same timestamp for files but not for folders. This is showed in the nextcloud web interface. This situation creates conflict when trying to sync with the clients.

In the filesystem, however, the folder timestamp (create and modify) are correct, as showed by stat.

Is this the first time you’ve seen this error? (Y/N):
Y

Steps to replicate it:

  1. Move the files to preserve the timestamp with rsync -avihXP --info=progress2 --stats source destination
  2. change the ownership with chown -R www-data:www-data /var/www/html/nextcloud
  3. check the timestamp with stat /var/www/html/nextcloud/data/user/files (the files and the folders have the correct timestamp)
  4. run sudo -u www-data php occ files:scan --all frow within /var/www/html/nextcloud
  5. open the browser and navigate to your nextcloud instance, the folders will have the modified field set the time of the file transfer
2 Likes

Hi, I met the exact same problem :

  • in filesystem, modification time is OK ;
  • in nextcloud ‘files’ app, “modification date” appears to be ctime and not “modification date”, thus it displays wrong info
1 Like

@nokoa77
I have this exact same problem. Did you ever figure out what was going wrong? The timestamps of the folders are the date the folder was rsync’d in to the NextCloud data dir whereas the timestamps of the files that are in the folders are correctly preserved.

Interestingly folders have correct timestamps if the folder is empty when it was rsync’d to the destination Nextcloud data dir.

I wonder is the problem related to the rsync command that is used?
In my case I rsync’d the contents of a data folder from one NextCloudPi install in to the data folder of another NextCloud install.

• Location of the “old” data folder:

/media/4TB1/ncdata/ncp/files

• Location of the “new” data folder:

/media/4TB1/nextcloud/data/ncp/files

• I copied the old Data dir to the new data dir using rsync:

sudo rsync -aAvzxh /media/4TB1/ncdata/ncp/files /media/4TB1/nextcloud/data/ncp

Actually when I go to the mysql db and look at the oc_filecache table I see that the timestamp for the folders is coming from ‘mtime’ and this is the time the rsync occurred instead of the folder modified time. However the ‘storage_mtime’ value in that table IS correct. It is the modified timestamp of the folder.

So why is ‘mtime’ telling the time the rsync command was run but ‘storage_mtime’ has the modified time of the folder?

I wonder if I should have used this rsync command instead:

sudo rsync -aAvzxhn /media/4TB1/ncdata/ncp/files/ /media/4TB1/nextcloud/data/ncp/files

Basically only rsync the “contents” of the ‘files’ directory from the source NextCloud data dir into the ‘files’ dir in the destination NextCloud data dir? Maybe replacing the ‘files’ dir with a new timestamp messes up the Nextcloud cache some way that affects the timestamps on folders?

I guess I can put everything back to the start again and try that. Unless if anyone has an answer to this problem I would really appreciate it. Thank you!

Cheers,

Flex