Howto sync a directory

138 views
Skip to first unread message

ste...@gmail.com

unread,
Aug 19, 2014, 1:58:44 PM8/19/14
to libr...@googlegroups.com
Hi,

I'm working on a backup sollution, using a qt gui which is triggered by right clicking on an item, and selecting "Backup".

This gui is storing every file and directory you want to backup in a mysql database.
The next step is to backup the directories and/or files by using:

rsync -aix --delete -r /path/to/list --out-format="%i|%n|" $HOME $BACKUP_MAP > $RSYNC_OUTPUT

The /path/to/list is a list of directories extracted from the mysql db.

Now depending on the output of rsync (RSYNC_OUTPUT, testing there are changes we are interested in) a snapshot is created:

btrfs subvolume snapshot %BACKUP_MAP "$SNAPSHOT_MAP/$DATE_FORMAT"

I want to write the step with rsync in the qt gui (so c++). How can I do this?
It's of course all about howto backup one file ( if there is a previous one) uring the function in librsync? Store the signature of a file in a list somewhere next to th backup?

Stef

Martin Pool

unread,
Aug 23, 2014, 12:16:49 PM8/23/14
to ste...@gmail.com, libr...@googlegroups.com
Hi,

I don't really understand the question. librsync doesn't sync directories and it doesn't run rsync; it only does data compression. 



--
You received this message because you are subscribed to the Google Groups "librsync" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librsync+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Martin

Stef Bon

unread,
Aug 23, 2014, 1:17:40 PM8/23/14
to Martin Pool, libr...@googlegroups.com
Hi,

No of course librsync does not run rsync.

please read the last part of my question. I see one typo, maybe that
is confusing. I mean librsync where I've written rsync.

There I explain that I want to use librsync in a qt gui to do the same
what rsync does.
How can I use librsync to compare a file with a previous version of
that file and if they differ, write the changes to the previous
version.

Stef

Martin Pool

unread,
Aug 23, 2014, 1:42:51 PM8/23/14
to Stef Bon, libr...@googlegroups.com
Well, if you say "with rsync" I'm going to think you want to use rsync. :)

So yes, you should store the signature when you make the backup. Then use it to compute a diff for the next version of the file.



Stef

--
You received this message because you are subscribed to the Google Groups "librsync" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librsync+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Martin

Stef Bon

unread,
Aug 23, 2014, 4:02:57 PM8/23/14
to Martin Pool, libr...@googlegroups.com
Aha. Thanks.

When there are no differences, how can I compute that?
When I look to the functions in librsync.h, I see
rs_loadsig_file
rs_file_copy_cb
rs_delta_file
rs_patch_file

now first, where is the rs_file_copy_cb function used? I do not see
any location in the other functions where it is used.

The normal way to program a backup is:

load the signature of the backup of the file, if there is any. If this
backup is not present, just copy and leave.
compute the delta of new file
if it's obvious the file do really differ (see my question above: how
to determine that) do patch the old file.

So how do I determine there are no differences. is it stored in
rs_result (when calling rs_delta_file)?

Stef

Martin Pool

unread,
Aug 23, 2014, 4:43:14 PM8/23/14
to Stef Bon, libr...@googlegroups.com
There's no direct report whether there are any differences. It would be useful to have one - you could file a feature request.

I would suggest any of
- check the ctime, mtime, and size
- store a hash redundantly with the signature (probably a good idea for safety) and check that before computing the signature
- compute the signature again and see if it's different
- just store the delta and rely on it being small if there's no actual changes

hth

--
You received this message because you are subscribed to the Google Groups "librsync" group.
To unsubscribe from this group and stop receiving emails from it, send an email to librsync+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages