Sync and copy timestamp

Lets say, I wrote a script to do synchronization between local drivers of my N computers and Storj.

I copy files to storj with command
uplink cp file sj://AAA/BBB

Now I have this situation:

  • File A for local disk of computer C1 with modification timestamp 2020-01-01, copied to storj with timestamp 2022-01-12 (today).
  • File A for local disk of computer C2 with modification timestamp 2021-01-01, copied to storj with timestamp 2022-01-13 (tomorrow) and overwrite previous version.
  • I am trying to sync computer C1 with Storj. How can I determine if file A on Storj is the original from C1 or has been modified, so C1’s file A must be overwritten from file A on Storj? Usually sync algorithms take advantage of size and date but here date is not exist as I expected.

Dirty workaround: keep for each computer the timestamp of last sync. If a file is newer than that timestamp, prevails.

Just for curiosity, is there anything better?

In Storj you cant modify written file, only delete old file and write new. So you can have backups from every day of a year for example, just put timestamp to files and make own path to every pc backup.

@nickreserved You could keep track of the file’s modification timestamp as metadata attached to the Storj object.

If you use Uplink CLI, this is using the --metadata flag in the cp command.
If you use the Uplink library, this is using the SetCustomMetadata method.

1 Like