Binary files migration
The upcoming major version6.0 release of Server Pro and Community Edition will reduce the storage usage of binary files in half. An online migration is included in version 5.5.7 , allowing for minimal downtime as part of the upgrade.
Since Server Pro 4.x, binary files are stored twice: in the active files storage in “filestore” and in the full project history system. Moving forward, a single copy of each file will be stored in the full project history system.
The migration to the consolidated storage system is composed of two parts: A new flag for controlling the phase of the migration and a script that processes all active and soft-deleted projects.
Phases:
OVERLEAF_FILESTORE_MIGRATION_LEVEL=0(default), files are read and written to filestore. Files are written to history asynchronously.OVERLEAF_FILESTORE_MIGRATION_LEVEL=1, files are read from history with fallback to filestore and written to both filestore and the history. Downgrade toOVERLEAF_FILESTORE_MIGRATION_LEVEL=0is possible.OVERLEAF_FILESTORE_MIGRATION_LEVEL=2files are read and written to history only. Downgrade toOVERLEAF_FILESTORE_MIGRATION_LEVEL=1is not possible, unless it was performed “offline”.
OVERLEAF_FILESTORE_S3_ACCESS_KEY_ID) and history (OVERLEAF_HISTORY_S3_ACCESS_KEY_ID): Please grant the filestore user read access to the history bucket for blobs OVERLEAF_HISTORY_PROJECT_BLOBS_BUCKET . The filestore service will serve reads from the compiler service moving forward.
The standard Server Pro license allows you to run the application in a production environment as well as one in a non-production/sandbox environment; it is highly recommended that you provision a non-production environment for testing.
If you upgrade to Server Pro/CE version
6.0 and later decide that you want to downgrade to an earlier version, then you should restore from a full system backup.Migration procedure
1
Create a backup
Create a full backup of your instance with a consistent snapshot of the mongo, redis and sharelatex directories.
2
Update
Toolkit: Use the
$ bin/upgrade script to upgrade the toolkit to the latest version. When asked, do not confirm the prompt Upgrade image? — instead, manually edit config/version file and set the value to 5.5.7.Legacy docker-compose.yml: Update the version of the sharelatex service to 5.5.7.3
Estimate the number of affected projects
4
Flush project history queues
"project_ids":0).In case “failedProjects” is not zero, please reach out to support and do not continue with the binary files migration.
5
Advance the migration phase to 1
Toolkit: Set
OVERLEAF_FILESTORE_MIGRATION_LEVEL=1 in config/variables.env.Legacy docker-compose.yml: Set OVERLEAF_FILESTORE_MIGRATION_LEVEL: '1' in the environment section of the sharelatex service.6
Apply the configuration change and start the instance
Toolkit:
bin/up -dLegacy docker-compose.yml: docker compose up -d7
Verify access to binary files
Open a project in the Overleaf editor in the browser and select a binary file, like an image.
8
Run the migration script
If you’re persisting log files outside the sharelatex container, ensure that the logs directory owner is set to the
www-data user (uid=33) so that the outputted log file can be written.0, and the last lines indicating no failures:9
Stop the instance
Toolkit:
bin/stop sharelatexLegacy docker-compose.yml: docker compose stop sharelatex10
Make old files inaccessible to the application
You can now move the old files to secondary storage. We recommend keeping the files around for a while in case issues arise later.
11
Advance the migration phase to 2
Toolkit: Set
OVERLEAF_FILESTORE_MIGRATION_LEVEL=2 in config/variables.env.Legacy docker-compose.yml: Set OVERLEAF_FILESTORE_MIGRATION_LEVEL: '2' in the environment section of the sharelatex service.12
Apply the configuration change and start the instance
Toolkit:
bin/up -dLegacy docker-compose.yml: docker compose up -d13
Verify access to binary files
Open a project in the Overleaf editor in the browser and select a binary file, like an image.
Offline migration
If you want to prevent users from being able to log in while the binary file migration script is running, please follow these steps:- Log into your Overleaf instance with an admin account
- Click on the Admin button and choose Manage Site
- Click the Open/Close Editor tab
- Click on the Close Editor button
- Click on the Disconnect all users button
Online migration
It is possible to run the migration scripts while the application is still running. There are a few considerations to take into account:- The migration process is IO intensive, you should monitor resource usage while the script is running.
- With a high processing concurrency, the event loop in
filestoreservice might experience some blocking, which would lead to a degraded user experience. We recommend starting with the default values of--concurrency=10and--concurrent-batches=1. - You can stop the script at any time. Starting it again will validate the previous projects and skip over files that have been processed already. This is useful in case you prefer to run the migration in less busy hours (e.g. at night).
--report). If the number of projects is large you can run the script and monitor its progress, then decide whether to continue running it online or offline based on your particular case.
Clean up legacy binary file data
When you are done with the migration and verified that projects can still access all their files, you can remove the old file storage in/var/lib/overleaf/data/user_files. We highly recommend keeping these files around for a while - you can make them inaccessible to the application by renaming the folder first.
Troubleshooting
We will add troubleshooting advice here. Please note that while we normally offer support only to Server Pro customers, given the nature of this migration, we will also do our best to support CE customers who experience problems specific to the binary file migration. If the binary file migration script fails (i.e. exits with an error or prints a non-zero number of failed projects), please send the following details to our support team by email support+filestoremigration@overleaf.com, detailing: Subject: Binary file migration problem Body:- Instance Type: CE or Server Pro (delete as appropriate)
- Installation Type: Overleaf toolkit or
docker-compose.ymlor other (delete as appropriate) - Version: 5.5.x (toolkit:
$ cat config/version) - Migration script output (which should be located in the container under
/var/log/overleaf) - Report: (run migration script with
--report) - Processed projects: (as per the last run of the script)
- Duration of the migration:
bin/doctoroutput (when using toolkit)- Toolkit version:
$ git rev-parse HEAD(when using Toolkit)
filestore service to the email. You can find it at /var/log/overleaf/filestore.log inside the sharelatex container and export them like this:
Missing files
Older versions of Server Pro/CE created file-tree entries before user uploads finished, which could cause files to appear as missing when an upload failed. You might find a few of these cases reported as errors when processing all the file-trees. In case the number of missing files is low, consider manually reviewing these cases and delete them from the editor in the browser. In case the number of missing files is high, consider reaching out to support, see email template above.Finding broken file trees
The migration may fail for projects which have a malformed file tree (for example, where filenames are empty). You can find a list of these problems using thefind_malformed_filetrees script which checks all projects in the database:
fix_malformed_filetree script, running the command once for each bad path:

