Emulate --link-dest type behaviour on local storage

Dear Rclone community
i have a situation where i want to create snapshots of an sftp share to a local machine using rclone. I can rclone sync the remote sftp share to local storage, but in order to keep those old snapshots i wanted to use something along the lines of rsync's --link-dest functionality, where unchanged files get hard-linked to the last snapshot.

I read in This Post that rclone does not support this, so I tried to replicate the behavior by creating a hardlinked copy of the last snapshot using cp -al snapshot1 snapshot2 prior to running the rclone command to sync the changes to snapshot2. However, this did not work, because rclone seems to modify changed files rather than replace them (delete + copy) which ment, that a changed file was now changed in both snapshot1 and snapshot2 as the hardlink was kept and onyl the contents where modified.

My solution was to use the --backup-dir option to solve this. looking at the verbose output of rclone, it seems that rclone first moves a changed file to the directory specified under --backup-dir and then copies the new version of it to the target directory.

So here is my solution on how I have implemented --link-dest behaviour using rclone and cp:

cp -al /backups/snapshot1 /backups/snapshot2 
rclone sync remoteserver:/source /backups/snapshot2 --backup-dir /backups/snapshot1

this seemst to do the trick. a file that was changed between snapshot1 and 2 kept the inode number in snapshot1 and got a new inode in snapshot2 and it holds the new content in snapshot2 while it still has the old content in snapshot1.

i am posting this to "help and support" rather than "HOWTO's" because i am looking for comments on this solution from more experienced users (this is the first time i'm using rclone).. can someone confirm that this is "the right way" to do what i wanted or did I miss anything?

kind regards
Pascal

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