S3 migration
These instructions are for v5.x and later. If you are following this guide for an earlier version please use
sharelatex instead of overleaf in path names and SHARELATEX_ prefix instead of OVERLEAF_ for environment variables. For v6 and later, skip the legacy user_files commands.We’d love to hear from you! If you’d like to share with us how many files you migrated over, their overall volume, and how long the migration took email
ayaka-notes@outlook.com .Requirements
- A S3 compatible object storage to talk to, see #s3-setup for options
- Free disk space for migrating existing data, about the current on disk size
- A maintenance window for doing the actual migration
- A full backup, including the config, to enable restoring from it
Estimate the disk size needed for the migration
We can usedu for calculating the current disk usage:
The history directories already have the correct layout. You can upload directly from the bind-mounted source folder, which does not require any additional disk space.
Migration steps
Step 0 shutdown the instance
We need to make sure that all user/template files will get migrated. It is best to shut down the instance to avoid missing newly uploaded files. Please see our guide on performing a consistent a backup for the shutdown procedure.Step 1 rewrite directory layout
We need to rewrite the directory layout of project files for uploading them to S3. The directory layout for local storage in filestore is<project-id>_<file-id> and the directory layout in S3 is <project-id>/<file-id>.
In the following, /srv/overleaf-s3-migration is used for storing the files in the new directory layout. Replace /srv/overleaf-bind-mount with the host directory mounted at /var/lib/overleaf. Run the copy commands on the host with permission to read and write these directories; the container remains stopped.
We can make use of tar for rewriting the layout:
Step 2 upload the files
Depending on your preference, you can use the minio mc S3 client or the aws cli for uploading the files to your S3 compatible object storage. aws cli- Here you should replace
overleaf-user-files,overleaf-template-files,overleaf-project-blobsandoverleaf-chunkswith the names of your S3 buckets. - Also replace
/srv/overleaf-bind-mountwith the local path of the/var/lib/overleafbind-mount. By default, this is~/overleaf_datain a docker-compose.yml deployment and<toolkit-checkout>/data/overleafwhen using the Toolkit.
Step 3 start the instance pointing at S3
Add all the S3 related variables to your config, as detailed in the Overview of variables section in the S3 setup guide. Keep the data-directory bind-mount: it may also contain Zotero or Mendeley encryption keys that are not migrated to S3.Please keep the bind-mount of a scratch disk for ephemeral files in place.
- can preview binary files in the editor
- can compile a PDF with images
- can upload new files
Rolling back
You can roll back the migration gracefully in reversing the steps:- Shutdown the instance
- Mirror back the files by flipping the sequence of source/destination
- Write new files back into the local directory using an inverse
transform - Restart the instance with the old configuration
The first transform removes the top level folder. The 2nd transform changes the directory layout to a flat one. The wildcards ensure that only files are extracted, not their parent (project) folders.

