Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP restore documentation about datastore format/manual decoding #16

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions doc/md/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,28 @@ find /var/www/links/cache/ /var/www/links/pagecache/ /var/www/links/tmp/ -type f
sudo systemctl restart apache2
```

### Datastore format

Bookmarks are stored in the `data/datastore.php` file [[1]](https://github.com/shaarli/Shaarli/blob/master/application/bookmark/BookmarkIO.php), in the form of a PHP array which is then serialized, then base64-encoded, then gzipped. This data is then enclosed between `<?php ... ?>` tags before being written to disk.

```bash
$ cat /var/www/shaarli.example.org/data/datastore.php
<?php /* 7P1bc9xYtiYIznOa5X9Axak6ETEdDt/3C3Py5FCkLpRImO5KRQ1VcwNYIMOEEdAAD8cXqyx8zhjNtYvVdZm/dRlbTY2dvptXrr7YZ4qZ/7I+QPdP2HWhruTLhGg6Ah3uWfonIwTQXff .... Nj9K+DWkdeZL993//+78= */ ?>
```

To display the array representing the data saved in `data/datastore.php`, use the following snippet:

```bash
php -r 'print(json_encode(unserialize(gzinflate(base64_decode(file_get_contents("data/datastore.php"))))));'
```

Alternatively, you can transform to JSON format (and pretty-print if you have `jq` installed):

```bash
php -r 'print(json_encode(unserialize(gzinflate(base64_decode(preg_replace("!.*/\* (.+) \*/.*!", "$1", file_get_contents("data/datastore.php")))))));' | jq .
```


-------------------------------------------------------

## Support
Expand Down
Loading