I assume everyone is familiar with Busuanzi. As the default visitor count statistics feature in the Butterfly theme, it's widely used across many static websites due to being a free public service. However, this popularity has also made Busuanzi a common reason for slowing down blog loading speeds. Last year, I came across Hong Ge's blog post about how to set up your own Busuanzi platform. Personally, I didn't notice much of a slowdown, so it stayed in my bookmarks without further action. Recently, I saw another friend's blog post on self-hosting the Busuanzi visitor statistics service. Although I still didn't feel any significant lag on my site, yesterday afternoon I couldn't resist tinkering with it. I ended up completing a private deployment and managed to restore previous data through a roundabout method.
Most experienced users opt for soxft/busuanzi: A simple web analytics tracker created by star-level contributors for private deployments, so I followed suit and adopted this project.
I won't elaborate too much on the setup process since online methods are generally consistent. I used Docker container orchestration for deployment.
Most people have port 8080 occupied, so you can change it to another port, for example: 6381:8080. Note that the latter 8080 is the container application port and should not be arbitrarily modified.
Change the final API_SERVER to your website URL. For instance, if your domain is busuanzi.lxink.cn, you should enter https://busuanzi.lxink.cn/api. Pay attention to SSL protocol issues.
Compared to the official configuration, I also mapped the redis container port to the local machine, which facilitates restoring previous Busuanzi data through indirect means.
After configuring the compose file, navigate to its directory via terminal and run docker-compose pull && docker-compose up -d to start the services. Finally, set up reverse proxy.
Note for butterfly: The ID name for private deployment is busuanzi_page_pv, whereas the theme's default is busuanzi_page_value_pv.
If you want to use Busuanzi statistics across your entire site, modify the following two locations:
Open the file themes\butterfly\layout\includes\widget\card_webinfo.pug and delete _value.

Open the file themes\butterfly\layout\includes\header\post-info.pug and change busuanzi_page_value_pv to busuanzi_page_pv.

Finally, in the configuration file, customize the CDN to include your JS file.

Any version of PHP with the redis extension installed.
Tiny RDM - A modern Redis GUI client.
Since this project doesn't synchronize with the official Busuanzi's APIs and methods, many users migrating to private deployment end up losing their historical data. This project stores data via a redis database. The dump.rdb file mounted under the redis directory cannot be directly opened, so I considered connecting to redis using database management software. Initially, I checked Navicat but found it doesn't support Redis connections. Fortunately, I recalled seeing a database connection tool recommended by Teacher Du on his blog, so I chose Tiny RDM for its compactness and lightweight nature.
This step requires using the port mapped to the local machine earlier. For example, in the configuration file above, the port mapping is 6380:6379, meaning 6380 is your external network connection port.

The default password is empty. For security reasons, please disable external network mapping after data restoration.
If connection fails, check whether the server security group allows the port.
Connected interface:

Since all data is encrypted with MD5, it might seem confusing at first. Below is the explanation provided by the developer:

Fortunately, my data volume was small. Currently, Busuanzi statistics are only used site-wide; article views still rely on Twikoo's page statistics. I plan to switch everything to Busuanzi soon.
Yesterday, after reviewing the structure, I came up with a data generation method—generating MD5 hashes in bulk to increase total site UV and thereby restore previous data.
I wrote a PHP script to achieve this:

Note that sadd does not apply to ZSET types.
After saving the PHP file, access its URL from your site directory to generate the specified quantity.




PV values can be directly modified. For page UV, you can adapt the method described above creatively.
This roundabout approach might seem clumsy, but it fulfilled my requirements.
For personal use, consider enabling cross-origin access to reduce unnecessary data.
The above results come from yesterday afternoon's tinkering. Last night, I also helped my friend Qingyu Feiyang with "data recovery." The method proved effective through multiple tests. If you have better solutions, feel free to discuss.