Skip to content

Commit

Permalink
Allow the profile name to be included in the backup path
Browse files Browse the repository at this point in the history
Otherwise you can clobber your backup when you switch profiles.
  • Loading branch information
gmcmanus committed May 6, 2020
1 parent 805f350 commit b6f1526
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ def main() -> None:

def backup() -> None:
config = mw.addonManager.getConfig(__name__)
backup_path = config['backup_path']
backup_path_template = config['backup_path']

if backup_path is None:
if backup_path_template is None:
return

backup_path = backup_path_template.format(profile_name=mw.pm.name)

# the collection is closed before the backup_did_complete hook, so reopen it
mw.reopen()

Expand Down
1 change: 1 addition & 0 deletions backup/config.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
`backup_path` is the path to do a full backup to. If it is null, no backup is performed.
The string `{profile_name}` in the backup path is replaced by the profile name.

1 comment on commit b6f1526

@tguilloryiii
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I hope all is well. I tried using this Anki addon. Pretty sure I'm not doing it right. lol

{
"backup_path": "C:/Users/User Name/Google Drive/anki-collection.colpkg"
}

I changed the path, but I think I was supposed to use the "profile_name" inside the path. Not exactly sure how to do that. For whatever reason, it's not backing up. I included the path as a string " " and I changed the backslash to forward slash as you have it here. Give me some tips on what do next? Thanks in advance.

Please sign in to comment.