davecan / SafeSuperMemo

Powershell script to manage SuperMemo from Dropbox, with timestamped backups
14 stars 3 forks source link

Backup multiple collections #1

Open rubisco57 opened 6 years ago

rubisco57 commented 6 years ago

Thank your sharing this script! I was looking for a good solution to keep my collections safe. Have you planned to integrate an option to backup multiple collections that sit in the same folder?

davecan commented 6 years ago

Glad it can help!

No I haven't addressed backing up multiple collections. This script isn't strictly a generic backup script per se -- it is a wrapper intended to protect a single collection at a time by replacing using the SM exe or shortcut directly. Basically you configure the script to point to a single collection, then run the script instead and it will disable Dropbox, back up that one collection, launch it in SM, then when SM is closed it will restart Dropbox. If you want to protect multiple collections you should make a separate copy of the script & config file for each. Ideally I would have modified the script to accept the config file as a parameter, but the current solution is the simplest thing that could possibly work for solving this particular problem. (well maybe it could be simpler, but this is simple enough)

There is some interesting development happening on the SM Discord server. One of the members is working on a major enhancement to SM through an external utility/driver written in C# (to replace some of our AutoHotKey customizations) and has already built an alpha version of a generic backup utility that will run block-level shadow copies of any folder you specify, so it shouldn't be affected by Dropbox/etc at all. But it is 0.1 alpha so given the criticality of SM collections to each of us I'm personally using this script for the foreseeable future. Once the other is more mature I may switch. His app is called BitShelter and is available in this repo: https://github.com/alexis-/BitShelter

rubisco57 commented 6 years ago

Thank you for your answer and suggestion. Alexis is doing amazing work! Unfortunately, BitShelter is not working on my system... for some reason :/ I will try to edit the script, in order to make it backup the collections in the same folder that are not in use - until then I will stick to your suggestion.

davecan commented 6 years ago

Glad to help.

If you want you can come to the Discord and I'm sure he would help you troubleshoot it in realtime. He's great about supporting the community. I think this invite still works, it's the one posted on the SuperMemoPedia wiki: https://discord.gg/pB7jcSK

We have several hardcore members there from around the world who have been using SM for many years, including one who has become good friends with Piotr Wozniak himself. In the 2 months or so since it launched we've had thousands of messages flying, and compiled a set of best practices summarized in the SuperMemoLore doc (92 pages last I checked) hosted on the SuperMemo repo (unofficial repo created by Alexis) found here: https://github.com/supermemo/SupermemoLore

LouisStAmour commented 5 years ago

Not sure if it helps anyone in particular, but I was looking for a quick way to create backups before launching SuperMemo and inspired by this repo's script I came up with a very short PowerShell script that gets the job done, backing up all the collections in my C:\SuperMemo\systems folder. It also stops running after launching SuperMemo, so I don't have an extra running process icon in my taskbar. As before, customize the first three variables to suit.

It uses robocopy to add retries to the file copy process but I've skipped the validation process which ideally would use hashes of the file contents to confirm files were copied as desired, it's just not that important to me if I've multiple copies of my backups already, though if there's an easy to use free tool for doing so, I'd consider swapping to it.

$collectionRootDir = "C:\SuperMemo\systems\"
$collectionName = "Louis Collection"
$backupRootDir = "C:\Users\louis\OneDrive\Documents\SuperMemo Backups\"

$backupName = (Get-Date).ToString("yyyyMMddTHHmmss") + " - " + $collectionName
$toDir = $backupRootDir + $backupName

robocopy $collectionRootDir $toDir /E /R:5 /W:5 /MT:8
$knoFilePath = $collectionRootDir + $collectionName + ".Kno"
Start-Process $knoFilePath -WorkingDirectory $collectionRootDir -PassThru

I don't feel the need to sync my collection over the internet yet, so I've dropped the sync killing feature. If I did need it, I'd probably try to sync a backup instead of the live SuperMemo directory. What I mean by this is I'd copy a backup to the cloud, then on the other computers, look for a more recent backup and copy it down before starting the app. This way the app is always running outside of the cloud sync sandbox, and the cloud sync is only used to upload backups after the app runs, and download backups before the app launches.

Theoretically, you could use the cloud to store app launch state -- like a lock file -- that way you could warn if the app was opened on multiple computers. If you saved the computer name to the lock file, you could tell yourself which computer had the app open, so you could go to it, presumably wake it from sleep, and close it. Or live with the data loss inherent from having a "split-brain" problem. Ideally there'd be a way to merge two collections by merging the actions done in both, as if replaying from a series of timestamps. But I haven't looked into things enough to know if there's such a replay log for state-modifying actions like that.