Data migration
Assets, attachments, resources, and objects are interchangeable terms that refer to the same thing: uploaded files.
Data storage location
Section titled “Data storage location”The .thumbnail_cache directory and its contents are generated as needed. You may ignore it
when migrating data.
Memospot
Section titled “Memospot”%LocalAppData%\Memospot$Env:LocalAppData\Memospot~/.memospotHidden folder in user’s Home. Toggle visibility with Ctrl+H or Cmd+Shift+.
Optional locations (if moved manually by the user)
~/.config/memospot$XDG_CONFIG_HOME/memospotMemos server
Section titled “Memos server”~/.memos/root/.memos/var/opt/memos%ProgramData%\memos$Env:ProgramData\memosBasic data migration
Section titled “Basic data migration”-
Close Memospot and/or stop the Memos Docker container.
-
Copy your
assetsfolder from source to the destination data directory. -
Copy
memos_prod.dbto the destination data directory. -
That’s it! Start Memospot or the Memos container on the destination.
Migrating data from old Memos versions
Section titled “Migrating data from old Memos versions”Legacy instructions
Section titled “Legacy instructions”Valid up to Memos v0.18.1. Superseded on Memos v0.18.2+.
Why this is documented here
Section titled “Why this is documented here”- Up to Memos v0.18.1, databases and assets were not portable. They pointed to absolute paths at the host’s file system, and moving data between systems required the instructions written on this page.
- Memos v0.18.2 started saving new assets with relative paths, but shipped a very slow path migrator for pre-existing assets.
- The asset path migrator was removed from Memos v0.19.1+.
- Memospot v0.1.3/v0.1.4 (bundled with Memos v0.20.0, compatible up to v0.21.0) shipped with its own fast asset migrator.
Introduction
Section titled “Introduction”This guide will help you migrate your Memos database and assets to a new host.
It’s possible to migrate between Windows and POSIX hosts, and between Memos Docker and Memospot, in any combination or direction. Just follow the appropriate steps.
If you only used the default Database object storage, you can skip the assets
migration part and just copy the database files to the new host.
Requirements
Section titled “Requirements”- A SQLite3 client, like DB Browser for SQLite.
- SSH access to your Docker host, if applicable.
- An SCP/SFTP client, like WinSCP and Cyberduck: to copy files to/from host, if needed.
Data migration
Section titled “Data migration”-
Close Memospot and stop your Docker container.
-
Copy your assets folder from source to destination host.
-
Copy the database files to a work directory on your local machine:
-
Open the copied
memos_prod.dbwith your SQLite client. -
Execute the appropriate SQL queries.
-
Write the changes to the database and close it.
-
Copy the modified
memos_prod.dbfile to the destination.
Replacing assets paths in the database
Section titled “Replacing assets paths in the database”The following queries assume the following:
- You are using the default internal Docker volume path
/var/opt/memos. - All your relative paths are using the default
assetsfolder.
If any of these assumptions do not hold for your setup, you must adjust the queries.
Queries
Section titled “Queries”The following sections contains queries to replace the assets paths in the database.
Pick one path style and click to expand:
Using absolute paths (up to Memos v0.18.0)
Getting the absolute Memospot data path:
echo "$HOME/.memospot"Write-Host "$Env:LocalAppData\memospot"Choose what best suits your migration scenario, then copy and adjust the SQL query:
-- Replace Windows paths with default internal Docker pathsUPDATE resource SET internal_path = REPLACE( internal_path, '__MEMOS_DATA_WINDOWS__', '/var/opt/memos');
-- Replace remaining Windows path separatorsUPDATE resource SET internal_path = REPLACE( internal_path, '\', '/');-- Replace Linux/macOS host paths with default internal Docker pathsUPDATE resource SET internal_path = REPLACE( internal_path, '__MEMOS_DATA_POSIX__', '/var/opt/memos');-- Replace Linux/macOS paths with Windows pathsUPDATE resource SET internal_path = REPLACE( internal_path, '__MEMOS_DATA_POSIX__', '__MEMOS_DATA_WINDOWS__');
-- Replace remaining POSIX path separatorsUPDATE resource SET internal_path = REPLACE( internal_path, '/', '\');-- Replace default internal Docker paths with Linux/macOS pathsUPDATE resource SET internal_path = REPLACE( internal_path, '/var/opt/memos', '__MEMOS_DATA_POSIX__');-- Replace default Docker volume paths with Windows pathsUPDATE resource SET internal_path = REPLACE( internal_path, '/var/opt/memos', '__MEMOS_DATA_WINDOWS__');
-- Replace remaining POSIX path separatorsUPDATE resource SET internal_path = REPLACE( internal_path, '/', '\');Using relative paths (starting from Memos v0.18.1)
These queries will replace absolute paths with relative paths.
Choose what best suits your scenario:
UPDATE resource SET internal_path = REPLACE( internal_path, SUBSTR( internal_path, 1, INSTR( internal_path, '/assets' ) ), '');UPDATE resource SET internal_path = REPLACE( internal_path, SUBSTR( internal_path, 1, INSTR( internal_path, '/assets' ) ), '');UPDATE resource SET internal_path = REPLACE( internal_path, '/', '\');UPDATE resource SET internal_path = REPLACE( internal_path, SUBSTR( internal_path, 1, INSTR( internal_path, '\assets' ) ), '');UPDATE resource SET internal_path = REPLACE( internal_path, '\', '/');After migration
Section titled “After migration”Execute the following query to check the first 100 rows:
SELECT type, filename, internal_path FROM resource WHERE internal_path IS NOT '' LIMIT 100;