umputun / remark42

comment engine
https://remark42.com
MIT License
4.77k stars 375 forks source link

Restore from Backup fails #1779

Open guyaevans opened 1 month ago

guyaevans commented 1 month ago

I am trying to restore a backup but it fails with:

remark42  | 2024/06/05 21:49:45.910 [INFO]  {logger/logger.go:134 logger.(*Middleware).Handler-fm.(*Middleware).Handler.func1.1} POST - /api/v1/admin/import?site=remark&provider=native - localhost - efaf335c4b7d - 202 (37) - 708.568µs - {"version":1,"users":[],"posts":[]} {"id": "1", "pid": "", "text": "<p>Hello, Just testing the comment system ;)</p>", "user": {"name": "Guy", "picture": "", "ip": "", "admin": false, "id": ["anonymous_46f13299136675607afcc89cd11d611070cfb4f4"]}, "locator": {"site": "remark", "url": "/posts/2022-11-13_bgp-ipv4-config-on-mikrotik-routerosv7/"}, "score": 0, "vote": 0, "time": "2022-12-22T17:29:49Z", "title": "BGP IPv4 Config on Mikrotik RouterOSv7"} {"id": "2", "pid": "", "text": "<p>I've enjoyed The Missing Crypto Queen for years now. It was quite a surprise when the infrequent updates started happening\u2014fulfilling too. You get the feeling the end of the story is around the corner now, with the latest episode late last year and the impending next one.</p>", "user": {"name": "Roger Overall", "picture": "", "ip": "", "admin": false, "id": ["anonymous_342791d445cafac9bad61a4cd1606b812b3e35b5"]}, "locator": {"site": "remark", "url": "/posts/2022-12-21_podcast-recommendations/"}, "score": 0, "vote": 0, "time": ...
remark42  | 2024/06/05 21:49:45.911 [DEBUG] {api/migrator.go:232 api.(*Migrator).runImport} import request for site=remark, provider=native
remark42  | 2024/06/05 21:49:45.917 [WARN]  {api/migrator.go:242 api.(*Migrator).runImport} import failed, failed to save 18 comments

This is the command I am using inside the docker container to trigger the restore:

remark42 restore -s remark -p var/backup/ -f output.gz --url http://localhost:8080

and its output:

remark42 v1.13.0-661f042-20240512T15:03:47
2024/06/05 21:49:45.905 [INFO]  {cmd/restore.go:21 cmd.(*RestoreCommand).Execute} restore output.gz, site remark
2024/06/05 21:49:45.905 [INFO]  {cmd/import.go:26 cmd.(*ImportCommand).Execute} import var/backup/output.gz (native), site remark
2024/06/05 21:49:45.912 [INFO]  {cmd/import.go:63 cmd.(*ImportCommand).Execute} completed, status=202, {"status":"import request accepted"}

This is an extract of the backup file:

{"version":1,"users":[],"posts":[]}
{"id": "1", "pid": "", "text": "<p>Hello, Just testing the comment system ;)</p>", "user": {"name": "Guy", "picture": "", "ip": "", "admin": false, "id": ["anonymous_46f13299136675607afcc89cd11d611070cfb4f4"]}, "locator": {"site": "remark", "url": "/posts/2022-11-13_bgp-ipv4-config-on-mikrotik-routerosv7/"}, "score": 0, "vote": 0, "time": "2022-12-22T17:29:49Z", "title": "BGP IPv4 Config on Mikrotik RouterOSv7"}
{"id": "2", "pid": "", "text": "<p>I've enjoyed The Missing Crypto Queen for years now. It was quite a surprise when the infrequent updates started happening\u2014fulfilling too. You get the feeling the end of the story is around the corner now, with the latest episode late last year and the impending next one.</p>", "user": {"name": "Roger", "picture": "", "ip": "", "admin": false, "id": ["anonymous_342791d445cafac9bad61a4cd1606b812b3e35b5"]}, "locator": {"site": "remark", "url": "/posts/2022-12-21_podcast-recommendations/"}, "score": 0, "vote": 0, "time": "2023-01-03T16:19:28Z", "title": "Podcast Recommendations"}

Let me know if you need anything else

VlasovArtem commented 1 month ago

Sorry, I am new to this project. But what I found is that the backup file has invalid structure for the user.id. Inside the backup file you have an array, but the system requires a string.

guyaevans commented 1 month ago

Sorry, I am new to this project. But what I found is that the backup file has invalid structure for the user.id. Inside the backup file you have an array, but the system requires a string.

Indeed that was the issue thanks !

Also should be noted the post url must be the full url for the page

paskal commented 1 month ago

@guyaevans, was the backup generated by the migration from another platform, from remark42 itself or manually?

Could some documentation be clarified to prevent this from happening to others?

I definitely should improve import error messaging so that the problem would be visible to the caller.