substance / notes

Real-time collaborative notes editing.
Other
21 stars 5 forks source link

Implement backup and restore utility #110

Closed michael closed 7 years ago

michael commented 8 years ago

Before we can start using Notes seriously we need to ensure that we don't loose data. Here's how we could do it.

Backup utility:

Usage: npm run backup path/to/backupfolder

Creates backupfolder containing a data.json file containing the same structure as our seed files. However we don't dump all changes. Instead for each document in the database we just dump a single change, containing ops representing the backed up document. That way we can use backup+restore to compress our database. Also let's not dump sessions, so users have to relogin after a restore. We also need to copy the uploads folder to that backup directory.

Restore utility:

Usage: npm run restore path/to/backupfolder

This will work similar to seeding, except also copying back the uploads folder.

michael commented 8 years ago

Still we need to think how we can save old data if the schema changes. For instance, when we remove comment.author and replace it with comment.userId, which soon we will do, how can we restore docs that have been written in the old Notes app?

In other words we have a backup that was done with notes beta.1 and we want to restore that data with notes beta 2. We will need some migration mechanism there. Like run this script x to convert document to new schema.

Integral commented 7 years ago

I think the best way to do it is to force snapshot for all docs. So we will export users, documents and snapshots. What do you think?

michael commented 7 years ago

Jeh that sounds good. Basically the backup can look like the seed fotmat.

Integral commented 7 years ago

I think I did it. Let's just close it until we will run into any problems.

Integral commented 7 years ago

And yes... After restoration version of all your docs will equal 1.