2020-07-01 05:52:17 -04:00
|
|
|
# Pad migration guide from etherpad-lite
|
2018-11-10 17:36:33 -05:00
|
|
|
|
|
|
|
The goal of this migration is to do a "dumb" import from all the pads in Etherpad, to notes in
|
2020-07-02 11:22:52 -04:00
|
|
|
HedgeDoc. In particular, the url locations of the pads in Etherpad will be lost. Furthermore, any
|
2018-11-10 17:36:33 -05:00
|
|
|
metadata in Etherpad, such as revisions, author data and also formatted text will not be migrated
|
2020-07-02 11:22:52 -04:00
|
|
|
to HedgeDoc (only the plain text contents).
|
2018-11-10 17:36:33 -05:00
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
Note that this guide is not really meant as a support guide. I migrated my own Etherpad to HedgeDoc,
|
2018-11-10 17:36:33 -05:00
|
|
|
and it turned out to be quite easy in my opinion. In this guide I share my experience. Stuff may
|
|
|
|
require some creativity to work properly in your case. When I wrote this guide, I was using
|
2020-07-01 05:52:17 -04:00
|
|
|
[etherpad 1.7.0][] and [codimd 1.2.1][]. Good luck!
|
2018-11-10 17:36:33 -05:00
|
|
|
|
|
|
|
## 0. Requirements
|
|
|
|
|
|
|
|
- `curl`
|
|
|
|
- running Etherpad server
|
2020-07-02 11:22:52 -04:00
|
|
|
- running HedgeDoc server
|
|
|
|
- [hedgedoc-cli][]
|
2018-11-10 17:36:33 -05:00
|
|
|
|
|
|
|
## 1. Retrieve the list of pads
|
|
|
|
|
|
|
|
First, compose a list of all the pads that you want to have migrated from your Etherpad. Other than
|
|
|
|
the admin interface, Etherpad does not have a dedicated function to dump a list of all the pads.
|
|
|
|
However, the Etherpad wiki explains how to list all the pads by [talking directly to the
|
|
|
|
database][howtolistallpads].
|
|
|
|
|
|
|
|
You will end up with a file containing a pad name on each line:
|
|
|
|
|
2020-07-01 05:52:17 -04:00
|
|
|
```bash
|
2018-11-10 17:36:33 -05:00
|
|
|
date-ideas
|
|
|
|
groceries
|
|
|
|
london
|
|
|
|
weddingchecklist
|
|
|
|
(...)
|
|
|
|
```
|
|
|
|
|
|
|
|
## 2. Run the migration
|
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
Download [hedgedoc-cli][] and put the script in the same directory as the file containing the pad names.
|
2018-11-10 17:36:33 -05:00
|
|
|
Add to this directory the file listed below, I called it `migrate-etherpad.sh`. Modify at least the
|
2020-07-02 11:22:52 -04:00
|
|
|
configuration settings `ETHERPAD_SERVER` and `HEDGEDOC_SERVER`.
|
2018-11-10 17:36:33 -05:00
|
|
|
|
|
|
|
```shell
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# migrate-etherpad.sh
|
|
|
|
#
|
2020-07-02 11:22:52 -04:00
|
|
|
# Description: Migrate pads from etherpad to HedgeDoc
|
2018-11-10 17:36:33 -05:00
|
|
|
# Author: Daan Sprenkels <hello@dsprenkels.com>
|
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
# This script uses the HedgeDoc command line script[1] to import a list of pads from
|
|
|
|
# [1]: https://github.com/hedgedoc/cli/blob/master/bin/hedgedoc
|
2018-11-10 17:36:33 -05:00
|
|
|
|
|
|
|
# The base url to where etherpad is hosted
|
|
|
|
ETHERPAD_SERVER="https://etherpad.example.com"
|
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
# The base url where HedgeDoc is hosted
|
|
|
|
HEDGEDOC_SERVER="https://hedgedoc.example.com"
|
2018-11-10 17:36:33 -05:00
|
|
|
|
|
|
|
# Write a list of pads and the urls which they were migrated to
|
|
|
|
REDIRECTS_FILE="redirects.txt"
|
|
|
|
|
|
|
|
|
|
|
|
# Fail if not called correctly
|
|
|
|
if (( $# != 1 )); then
|
|
|
|
echo "Usage: $0 PAD_NAMES_FILE"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Do the migration
|
|
|
|
for PAD_NAME in $1; do
|
|
|
|
# Download the pad
|
|
|
|
PAD_FILE="$(mktemp)"
|
|
|
|
curl "$ETHERPAD_SERVER/p/$PAD_NAME/export/txt" >"$PAD_FILE"
|
2019-03-27 14:31:20 -04:00
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
# Import the pad into HedgeDoc
|
|
|
|
OUTPUT="$(./hedgedoc import "$PAD_FILE")"
|
2018-11-10 17:36:33 -05:00
|
|
|
echo "$PAD_NAME -> $OUTPUT" >>"$REDIRECTS_FILE"
|
|
|
|
done
|
|
|
|
```
|
|
|
|
|
|
|
|
Call this file like this:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
./migrate-etherpad.sh pad_names.txt
|
|
|
|
```
|
|
|
|
|
2020-07-02 11:22:52 -04:00
|
|
|
This will download all the pads in `pad_names.txt` and put them on HedgeDoc. They will get assigned
|
2018-11-10 17:36:33 -05:00
|
|
|
random ids, so you won't be able to find them. The script will save the mappings to a file though
|
|
|
|
(in my case `redirects.txt`). You can use this file to redirect your users when they visit your
|
|
|
|
etherpad using a `301 Permanent Redirect` status code (see the next section).
|
|
|
|
|
|
|
|
## 3. Setup redirects (optional)
|
|
|
|
|
|
|
|
I got a `redirects.txt` file that looked a bit like this:
|
|
|
|
|
2020-07-01 05:52:17 -04:00
|
|
|
```log
|
2020-07-02 11:22:52 -04:00
|
|
|
date-ideas -> Found. Redirecting to https://hedgedoc.example.com/mPt0KfiKSBOTQ3mNcdfn
|
|
|
|
groceries -> Found. Redirecting to https://hedgedoc.example.com/UukqgwLfhYyUUtARlcJ2_y
|
|
|
|
london -> Found. Redirecting to https://hedgedoc.example.com/_d3wa-BE8t4Swv5w7O2_9R
|
|
|
|
weddingchecklist -> Found. Redirecting to https://hedgedoc.example.com/XcQGqlBjl0u40wfT0N8TzQ
|
2018-11-10 17:36:33 -05:00
|
|
|
(...)
|
|
|
|
```
|
|
|
|
|
|
|
|
Using some `sed` magic, I changed it to an nginx config snippet:
|
|
|
|
|
2020-07-01 05:52:17 -04:00
|
|
|
```nginx
|
2018-11-10 17:36:33 -05:00
|
|
|
location = /p/date-ideas {
|
2020-07-02 11:22:52 -04:00
|
|
|
return 301 https://hedgedoc.example.com/mPt0M1KfiKSBOTQ3mNcdfn;
|
2018-11-10 17:36:33 -05:00
|
|
|
}
|
|
|
|
location = /p/groceries {
|
2020-07-02 11:22:52 -04:00
|
|
|
return 301 https://hedgedoc.example.com/UukqgwLfhYyUUtARlcJ2_y;
|
2018-11-10 17:36:33 -05:00
|
|
|
}
|
|
|
|
location = /p/london {
|
2020-07-02 11:22:52 -04:00
|
|
|
return 301 https://hedgedoc.example.com/_d3wa-BE8t4Swv5w7O2_9R;
|
2018-11-10 17:36:33 -05:00
|
|
|
}
|
|
|
|
location = /p/weddingchecklist {
|
2020-07-02 11:22:52 -04:00
|
|
|
return 301 https://hedgedoc.example.com/XcQGqlBjl0u40wfT0N8TzQ;
|
2018-11-10 17:36:33 -05:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
I put this file into my `etherpad.example.com` nginx config, such that all the users would be
|
|
|
|
redirected accordingly.
|
2020-07-01 05:52:17 -04:00
|
|
|
|
|
|
|
[etherpad 1.7.0]: https://github.com/ether/etherpad-lite/tree/1.7.0
|
2020-11-14 16:24:44 -05:00
|
|
|
[codimd 1.2.1]: https://github.com/hedgedoc/hedgedoc/tree/1.2.1
|
2020-07-02 11:22:52 -04:00
|
|
|
[hedgedoc-cli]: https://github.com/hedgedoc/cli/blob/master/bin/hedgedoc
|
2020-07-01 05:52:17 -04:00
|
|
|
[howtolistallpads]: https://github.com/ether/etherpad-lite/wiki/How-to-list-all-pads/49701ecdcbe07aea7ad27ffa23aed0d99c2e17db
|