MobileSheets Forums

Full Version: Restoring Database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I copied all songs in a collection into a set list and then removed several songs.

Unfortunately, I meant to remove them from the set list and not the collection!

As it happens, I did make a backup with the Companion this morning so I wouldn't lose much restoring the database.
I tried selecting all the songs in the copied set list and created a collection. However, this loses all the song modification dates; probably not the end of the world but I do sometimes sort by modified date. It looks like the file creation data is preserved. 
So should the modified date be changed when one adds a file to a list ? (the file hasn't changed but the list has)

To retain the modified dates, I'm guessing I could just extract the .db file from the backup and replace the one on the tablet - would that work and is that sufficient?

If I choose to restore the full backup, do I need to do anything first (like delete existing files and restart MSP to create an empty database). If I do restore, will the modified dates be maintained or will they be set to the date of the restoration (if the restoration date is used then there isn't much point doing a restore).


Last modified timestamps for songs are preserved after performing a restore. On Android, MobileSheetsPro tries to also set the last modified timestamps of files to what is stored in the database but this is not guaranteed to work on every device. I have no control over this - it's an OS file thing. On Windows 10, I have no ability to control the last modified timestamp - Microsoft does not allow it to be changed. If the file timestamp changes, then when you load a song, it will scan for changes, which can result in the song updating the last modified timestamp for itself as well. 

You can certainly replace the database file from one in the backup, but the same problem may occur - if the last modified timestamp for a file in the database does not match the last modified timestamp on the actual file system, the song will scan for changes and the last modified timestamp will be changed as a result of this. I'm not sure I have a good answer for this. I think what I will have to do is make the logic used when scanning for changes more intelligent. If no change occurs to the song, then I won't update the last modified timestamp. One thing I could do to make this logic a lot faster is to add a crc calculation field to the files table in the database. I could then just calculate a CRC on the new version of the file, and if it matches the old version then I know nothing has changed. Until that is implemented though, I'll have to check to make sure the file type matches, the number of pages matches, and the size of each page matches.

Thanks for the explanation Mike

Do I need to clear the data folder before doing the restore  (I suppose I could just rename the folder and then give it a go)

No, you don't need to clear the folder, the restore will overwrite the files and delete them if necessary. 

Thanks for the advice Mike.

Although all the files were still in place, I opted to do a full restore via the companion.
Very easy and quick.
It all looks ok 

I was lucky this time because I don't normally backup the database; I only backed up because I was upgrading MSP. 
Moral: Back up the database whenever it contains changes you don't want to lose!

(03-22-2019, 02:58 AM)Geoff Bacon Wrote: [ -> ]Moral: Back up the database whenever it contains changes you don't want to lose!

Backup the database whenever always.

It's not just that I hate losing things. Sometimes it is just not possible to recover from a backup and remember all (yes, I mean all) changes that you applied after the backup.

I have a nightly daemon on my (Linux) PC that copies the database from the tablet and stores it aways in a safe place. It allows me to do off-tablet checks on the database as well as emergency recovery.

If I could teach MSPro to perform a "Sync Library to Cloud" automatically I would definitely do that as well.
I use FolderSync (Android) to copy mobilesheets.db automatically to GoogleDrive.
@scirius and itsme

Thanks for your suggestions