🚀 Feature: Export/Import app data #142

Open
opened 2025-10-07 23:54:46 +03:00 by OVERLORD · 9 comments
Owner

Originally created by @rheicide on GitHub.

Originally assigned to: @stonith404 on GitHub.

Feature description

A new section probably in the Application Configuration or a CLI command that allows an admin to export/import a Pocket ID instance's data to/from a file.

Pitch

One use case would be to export all app data and configuration (including users' data) from an instance using SQLite and then import them into a fresh instance configured to use Postgres.

Originally created by @rheicide on GitHub. Originally assigned to: @stonith404 on GitHub. ### Feature description A new section probably in the Application Configuration or a CLI command that allows an admin to export/import a Pocket ID instance's data to/from a file. ### Pitch One use case would be to export all app data and configuration (including users' data) from an instance using SQLite and then import them into a fresh instance configured to use Postgres.
Author
Owner

@rheicide commented on GitHub:

Thank you for your feedback 🙏🏾

Yes, a CLI solution makes sense. I initially suggested a UI integration because of Pocket ID's excellent UI/UX which has allowed me to do everything I needed so easily.

Regarding dumping the database, I think it would be great if this feature could be database-agnostic so that the data export could be used with any Pocket ID setup. IMHO making this kind of migration hassle-free would further improve user experience.

@rheicide commented on GitHub: Thank you for your feedback 🙏🏾 Yes, a CLI solution makes sense. I initially suggested a UI integration because of Pocket ID's excellent UI/UX which has allowed me to do everything I needed so easily. Regarding dumping the database, I think it would be great if this feature could be database-agnostic so that the data export could be used with any Pocket ID setup. IMHO making this kind of migration hassle-free would further improve user experience.
Author
Owner

@ItalyPaleAle commented on GitHub:

If not in the UI, it could be a command in the CLI too

@ItalyPaleAle commented on GitHub: If not in the UI, it could be a command in the CLI too
Author
Owner

@stonith404 commented on GitHub:

If we would add this, I agree with @ItalyPaleAle that it makes more sense to add this functionality to the CLI instead of adding it to the UI.

Like @kmendell said, it should be pretty easy to export the data, by creating a database dump and copying the data/uploads folder to the new place. If this issue gets more uploads we can consider to create an easier solution with the CLI though.

@stonith404 commented on GitHub: If we would add this, I agree with @ItalyPaleAle that it makes more sense to add this functionality to the CLI instead of adding it to the UI. Like @kmendell said, it should be pretty easy to export the data, by creating a database dump and copying the `data/uploads` folder to the new place. If this issue gets more uploads we can consider to create an easier solution with the CLI though.
Author
Owner

@kmendell commented on GitHub:

You could technially do this by doing a database export already, im assuming you are wanting a more user friendly way to do so?

@kmendell commented on GitHub: You could technially do this by doing a database export already, im assuming you are wanting a more user friendly way to do so?
Author
Owner

@ItalyPaleAle commented on GitHub:

So the problem with something that's database agnostic is that then we have a new format we need to maintain. For example, if the database schema gets updated, we need to make sure that we can also always import older data and "migrate" that too.

@ItalyPaleAle commented on GitHub: So the problem with something that's database agnostic is that then we have a new format we need to maintain. For example, if the database schema gets updated, we need to make sure that we can also always import older data and "migrate" that too.
Author
Owner

@ItalyPaleAle commented on GitHub:

I think the import process will need to support database schema changes regardless of whether the feature is database-agnostic or not.

You are certainly correct here. The advantage of doing a full DB export is that the data will also contain the migration version, so the migration library will just pick up from that point onwards. So we wouldn’t need to anything additional to migrate the data to a new schema.

As a starting point, we could require the export and import to be done by the same version of Pocket ID

A valid suggestion for sure, but may be hard with the current pace of development of Pocket ID. Things are changing fast so there are new versions multiple times per month right now.

@ItalyPaleAle commented on GitHub: > I think the import process will need to support database schema changes regardless of whether the feature is database-agnostic or not. You are certainly correct here. The advantage of doing a full DB export is that the data will also contain the migration version, so the migration library will just pick up from that point onwards. So we wouldn’t need to anything _additional_ to migrate the data to a new schema. > As a starting point, we could require the export and import to be done by the same version of Pocket ID A valid suggestion for sure, but may be hard with the current pace of development of Pocket ID. Things are changing fast so there are new versions multiple times per month right now.
Author
Owner

@cweagans commented on GitHub:

Prior art to consider: Gitea has a dump/restore command in its CLI. It's really nice. Being able to run a single command to create/restore a backup would be amazing. In the mean time, I'm taking a snapshot of the data directory (excluding the database) + running sqlite3 pocket-id.db "VACUUM INTO 'pocket-id.backup.db' periodically.

@cweagans commented on GitHub: Prior art to consider: Gitea has a dump/restore command in its CLI. It's really nice. Being able to run a single command to create/restore a backup would be amazing. In the mean time, I'm taking a snapshot of the `data` directory (excluding the database) + running `sqlite3 pocket-id.db "VACUUM INTO 'pocket-id.backup.db'` periodically.
Author
Owner

@rheicide commented on GitHub:

@ItalyPaleAle Please correct me if I'm wrong, but I think the import process will need to support database schema changes regardless of whether the feature is database-agnostic or not.

As a starting point, we could require the export and import to be done by the same version of Pocket ID to reduce the initial complexity and allow phased development of this feature.

@rheicide commented on GitHub: @ItalyPaleAle Please correct me if I'm wrong, but I think the import process will need to support database schema changes regardless of whether the feature is database-agnostic or not. As a starting point, we could require the export and import to be done by the same version of Pocket ID to reduce the initial complexity and allow phased development of this feature.
Author
Owner

@stonith404 commented on GitHub:

#998 would introduce the ability to import and export all data from the CLI. The usage is like this:

Export:

docker compose exec pocket-id /app/pocket-id import ./pocket-id-export.zip
docker compose cp pocket-id:/app/pocket-id-export.zip <path-on-your-machine/pocket-id-export.zip

Import:

docker compose cp <path-on-your-machine/pocket-id-export.zip pocket-id:/app/pocket-id-import.zip
docker compose exec pocket-id /app/pocket-id import ./pocket-id-import.zip

I would appreciate if some of you guys test this new feature because there might be edge cases where it can fail. Make sure to back everything up first. If you are using Sqlite you can simply create a backup of the data folder.

The feature is available with the ghcr.io/pocket-id/pocket-id:pr-998 image.

@stonith404 commented on GitHub: #998 would introduce the ability to import and export all data from the CLI. The usage is like this: Export: ```sh docker compose exec pocket-id /app/pocket-id import ./pocket-id-export.zip docker compose cp pocket-id:/app/pocket-id-export.zip <path-on-your-machine/pocket-id-export.zip ``` Import: ```sh docker compose cp <path-on-your-machine/pocket-id-export.zip pocket-id:/app/pocket-id-import.zip docker compose exec pocket-id /app/pocket-id import ./pocket-id-import.zip ``` I would appreciate if some of you guys test this new feature because there might be edge cases where it can fail. Make sure to back everything up first. If you are using Sqlite you can simply create a backup of the `data` folder. The feature is available with the `ghcr.io/pocket-id/pocket-id:pr-998` image.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id-pocket-id-1#142