On 13 Feb 2015, at 10:19pm, Mayank Kumar (mayankum) <mayankum at cisco.com> wrote:
> -by syncing, I mean taking the modifications on the active machine and > sending over wire to another machine(in some proprietary format) , where > there is a similar sqlite application which receives the records and the > records are written to a sqlite db residing on that machine using a sqlite > apis. > -when the two sqlite applications come up on the active and standby machines > for the FIRST time, we ALSO do a rsync of the sqlite db from the active to > standby to make them same and then subsequently sqlite applications keep in > sync using the mechanism I highlighted in 1 above. In this process, when we > do a rsync, does it make sense to copy the journal file which was created by > the application, so that after the rsync is completed and the sqlite > application on the standby side comes up, it can recover any lost > transactions before it starts to receive record by record copies which it > will write to its own db using sqlite apis. First, it's a bad idea to copy (using rsync or anything else) the database while an application has the database open. You run the risk of copying a file while it's being modified and if you do that it will be corrupt. (It may be corrupt in a way that can be rescued, but it's still a bad thing to do.) Second, any journal file goes with the database file. If the database was closed properly there shouldn't be any journal files. If the database app crashed or is still running there may be a journal file and some of your data will be in the journal file /and not in the database file/. So any time you copy the .sqlext file (or whatever extension you use), look for any related temporary or journal files in the same folder and copy those too. One way to do this easily is to give the database file a prefix which you don't use for anything else in that folder. So if, for example, your database file is thatfolder/myappdata.sqlext when when you rsync make sure you get all the files covered by thatfolder/myappdata*.* . This will ensure that your system works fine no matter what journal mode you're using and no matter what you happened to be doing when your app/system/computer crashed. It's also a little future-proof against things sqlite may do in the future. Simon.