How to Fix Nextcloud Sync Issues with File Modification Dates on Linux
TL;DR
Nextcloud Desktop Sync can fail when file modification dates are earlier than creation dates. Fix it by updating timestamps with touch -m
for individual files, directories, or recursively through your entire sync folder.
The Problem
Recently, I ran into a weird issue with my Nextcloud Desktop sync on Linux (the issue was in Aurora Linux, but should apply for other distros and systems). Some files simply refused to sync. After some investigation (aka: read the logs in the app), I discovered the culprit: the modification dates on some files were earlier than their creation dates, confusing Nextcloud's synchronisation algorithm.
I still don´t know how that happened. The files in questions were from a data export from ChatGPT, which had a creation date of, say, 2025-03-16 and a modification date of 1980-01-01, which does not make any sense.
The Solution
The fix turned out to be surprisingly simple: updating the modification timestamps of the problematic files and folders using the touch
command.
touch
is a command used to update the access date and/or modification date of a computer file or directory. - https://en.wikipedia.org/wiki/Touch_(command)
For a Single File
To update just one file:
touch -m /path/to/file
For a Directory (Just the Folder Itself)
To update just the directory's modification date (not the contents):
touch -m /path/to/directory
Important: touch -m folder
only updates the timestamp of the folder itself, not any of the files inside it.
For All Files in a Directory
To update all files in a directory:
find /path/to/directory -type f -exec touch -m {} \;
How I Fixed My Sync
In my case, I had a folder structure with 51 files that wouldn't sync. Here's what I did:
- First, I identified which folders weren't syncing by checking the Nextcloud client logs
-
I ran the following commands on my problematic folders and folders:
bash find /path/to/directory -type f -exec touch -m {} \; touch -m /path/to/directory
-
I issued a re-sync through the Nextcloud desktop client or closed and reopened the Desktop App to restart the sync process.
After a few minutes (depending on how many files you have), everything should be synced perfectly!
Why This Works
The touch -m
command updates the modification time of a file or directory to the current time. By doing this, you ensure that:
- All modification dates are now newer than creation dates
which should, in turn, do the following
- The updated timestamps trigger Nextcloud to recognize the files as "changed"
- The sync algorithm properly processes them during the next sync cycle
Happy syncing!