Aaron Ellington

How to tell if the sync is complete for a folder from bash

Recommended Posts

Is it possible to tell is a folder is fully synced/currently syncing or not from command line/bash? 

Background: My shared folders are zfs filesystems on my Ubuntu 16.04 server and I want to setup a cron job to take a zfs snapshot as long as a btsync is not currently syncing with a peer. 

 

Thanks in advance for your help!

Share this post


Link to post
Share on other sites

I am not a professional user but to share my thinking. I think you could first to pausing the sync and then take snapshot of those folders without tmp sync file ext names...Yes, but for those files got not synced yet.. this method is not ideal...

Share this post


Link to post
Share on other sites
10 hours ago, YI WANG said:

I am not a professional user but to share my thinking. I think you could first to pausing the sync and then take snapshot of those folders without tmp sync file ext names...Yes, but for those files got not synced yet.. this method is not ideal...

That may be something though. I can have my script check to see the the directory has any files with the .bts extension before taking the zfs snapshot. I think that would work just fine. I'll test it out and let you know if that works well enough or not.  

From looking at on of my shares it appears that .bts is a tmp extension. Is that the only one I should check for, or are there more?

Share this post


Link to post
Share on other sites

@Aaron Ellington,

I think I must warn you, that in Resilio Sync v.2.4 those temp files (rsls, formerly bts) will no longer appear in the folder until the file is fully downloaded. So your script won't help there. 
 

Share this post


Link to post
Share on other sites

Also, doing this introduces races. What if a file starts syncing in a directory while you are checking for temporary files.

Did you consider stopping/starting via your init system?

Share this post


Link to post
Share on other sites
1 hour ago, Aaron Ellington said:

 

@iswrong I can stop it before taking the snapshot then start it again. But I would still have the problem of stopping the sync while it's in the middle of syncing. How would you solve that problem?

I would think (but didn't check) that Sync would exit gracefully when it receives a SIGTERM signal. (As in: the sync may not be complete, but everything is in a consistent state.)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.