Important upgrade can be done only to offline database. So instead we will create new upgraded cluster and switch our application to use it.
We tried to automate upgrade upgrade as much as possible, based on the one of the official migration guides, however, some manual operations are needed in any case.
-
(Optionally) Enable logging of all queries (set
SlowQueryLog
to0ms
) on the current cluster. -
Create NEW neo4j stack, similar to existing one with following differences:
- Set
UpgradeMode
totrue
- Set
BackupPath
to latest s3 backup path from current cluster, for example:neo4j-testing-cluster-backup/hourly/neo4j-backup-1611139867.zip
- Use some different
CloudMapNamespaceName
from the one used in the old cluster. - Make sure, to create disk big enough to store ~2.5x of current data: DB size + Unzipped backup size and to have free space left.
- Set
-
Wait for Neo4j node to come online
-
Open the CloudWatch logs (can be found in CloudFormation UI -> Stack -> Resources tab ->
CloudwatchLogsGroup
):-
Find following line:
You have to manually apply the above commands to the database when it is stared to recreate the indexes and constraints
Well, it means what it says, this commands will be needed to run manually once cluster is ready
-
Find the result of S3 upload of
.dump
file, and copy its S3 path (likeneo4j-test-cluster/dumps/neo4j-1611146313.dump
)
-
-
Stop cluster as described in (
README.md
) -
Now we need to update our stack changing following parameters:
- Set
UpgradeMode
tofalse
- Set
BackupPath
to the.dump
file from previous step
- Set
-
Wait for cluster to come online
-
Apply the queries from the step before: Can be done via WebUI, copying queries from CloudWatch one by one or
SSH to the instance, that were used for initial migration:
docker exec -it <container_id> bash cat logs/neo4j-admin-copy-*.log | grep "CALL"` # Copy results into buffer /var/lib/neo4j/bin/cypher-shell -u neo4j -p $NEO4J_ADMIN_PASSWORD -a neo4j://core.<neo4j-domain>:7687 # Paste results from buffer # (keep in mind, that last query is missing `;` for some reason, so you will have to add it)
-
Done. Now you would want to point your application so the new cluster.
However, while you were performing this steps, old cluster were still in use and some new data were written there. And now your data is outdated, what you can do, is to find all the relevant write queries made to your old cluster mad after the backup you used to create new cluster from and replay them on the new cluster. This is not perfect, but at least something 🤷