Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete Migrations of Bookwyrm Accounts across instances #2980

Merged
merged 1 commit into from
Oct 15, 2023

Conversation

CSDUMMI
Copy link
Contributor

@CSDUMMI CSDUMMI commented Sep 5, 2023

This PR aims to implement #1012. It introduces new export and import functionality, that allows users to export their entire account and all associated media in a self-contained tar file.

Archive structure

The tar.gz archive contains three parts:

  1. archive.json: Containing the user settings, names and books used by the user.
  2. avatar.png/avatar.jpg: A user's avatar image if present
  3. covers/: the book covers used by the user

Implementation

This project was implemented in collaboration during the first Guild Alpha Sprint.

We decided to use a custom JSON archive as the basis of this proposal, as @hughrun had already done work on that, which we used as a base.

On this we added:

  • Improved serialization of the archive.json
  • Move exporting and importing to celery tasks
  • Wrap the archive.json into a tar archive
  • Add media files to the archive
  • Unit Tests of the import and export process

Due to time constraints we couldn't implement everything needed. Here are the tasks, that we know of, that still need work:

  • Cool-down period between creating archives to prevent overloading the server
  • Regularly scheduled task to remove old archives according to an environment variable
  • Notification on import & export completion
  • Error handling & retry mechanism. Currently when an import or export fails the Task status remains active. The status doesn't show "failed" and no error is given.
  • Admin controls

Hopefully with our work as a base, the remainder can be undertaken by BookWyrm itself to bring this PR to completion.

Screenshots

import-example

export-example

Known Bugs

test_export_user.py Errors

  • ExportUserViews.test_download_export_user_file is throwing: bookwyrm.models.bookwyrm_export_job.BookwyrmExportJob.DoesNotExist: BookwyrmExportJob matching query does not exist.
  • ExportUserViews.test_export_user_get is throwing: Exception: line 367 column 5 - Warning: inserting implicit <p>

Contributors:

Special thanks to @Ryuno-Ki and @circlebuilder

…etween instances (bookwyrm-social#38)

Co-authored-by: Daniel Burgess <developerdannymate@gmail.com>
Co-authored-by: Hugh Rundle <hugh@hughrundle.net>
Co-authored-by: dannymate <dannymate@noreply.codeberg.org>
Co-authored-by: hughrun <hughrun@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/GuildAlpha/bookwyrm/pulls/38
Co-authored-by: CSDUMMI <csdummi.misquality@simplelogin.co>
Co-committed-by: CSDUMMI <csdummi.misquality@simplelogin.co>
@hughrun
Copy link
Contributor

hughrun commented Sep 30, 2023

@CSDUMMI we need to fix a couple of things before pulling this into main. Can you please change the target branch to user-migration? We can then deal with any merge conflicts, pull it across, and will have a branch to work with on the main bookwyrm repository instead of trying to run through your repo.

@CSDUMMI CSDUMMI changed the base branch from main to user-migration October 1, 2023 18:57
@CSDUMMI
Copy link
Contributor Author

CSDUMMI commented Oct 1, 2023

I've changed the base branch now.

I'm available to answer any further questions on this here.

@hughrun hughrun removed the request for review from mouse-reeve October 15, 2023 04:18
@hughrun hughrun merged commit f07d730 into bookwyrm-social:user-migration Oct 15, 2023
6 of 10 checks passed
@hughrun hughrun mentioned this pull request Oct 22, 2023
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants