From f5a769635c73be02b4d97913f746d7ebbc2c8725 Mon Sep 17 00:00:00 2001 From: nodiscc Date: Fri, 15 Sep 2023 16:13:32 +0200 Subject: [PATCH] WIP restore documentation about datastore format/manual decoding --- doc/md/Troubleshooting.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/doc/md/Troubleshooting.md b/doc/md/Troubleshooting.md index 334779ba7..325fe5d0b 100644 --- a/doc/md/Troubleshooting.md +++ b/doc/md/Troubleshooting.md @@ -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 `` tags before being written to disk. + +```bash +$ cat /var/www/shaarli.example.org/data/datastore.php + +``` + +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