[Bug] Please link "Create a backup of your database." to relevant documentation. #1037

Closed
opened 2025-12-29 02:27:51 +01:00 by adam · 3 comments
Owner

Originally created by @tgrushka on GitHub (May 27, 2025).

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Please link the bold instruction to Create a backup of your database to relevant documentation (add docs if they don't exist) on:
https://github.com/juanfont/headscale/blob/main/docs/setup/upgrade.md

I found the config in:

database:
  sqlite:
    path: /var/lib/headscale/db.sqlite

and copied it to my home directory with:

sudo systemctl stop headscale
sudo cp /var/lib/headscale/db.sqlite headscale-backup-$(date +%Y%m%d).sqlite

... do upgrade ...

sudo systemctl start headscale

It consumed 15-20 minutes + frustration + time to write up this issue and switch contexts to figure out how to do this, when a few lines of documentation could have just told me how to do it.

My philosophy is that, if we each only help ourselves, we have only one person helping us. But when we help others, we potentially have millions of others helping us. I know which world I would rather live in, but I'm afraid our current society oddly values the former over the latter. 😃 I mean, when we document our own code (I am never offended by documentation that is written to be "fool proof"), we free others' energy so that they can focus on contributing back to our own projects in return.

Thank you.

Expected Behavior

I expected a link to docs on how to backup the database.

Steps To Reproduce

Read the docs on how to do an upgrade and find there is no reference on how to backup.

Environment

- OS: Debian GNU/Linux 12 (bookworm)
- Headscale version: v0.25.1 (I need to upgrade, hence this issue)
- Tailscale version: N/A

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Debug information

Not relevant to the issue.

Originally created by @tgrushka on GitHub (May 27, 2025). ### Is this a support request? - [x] This is not a support request ### Is there an existing issue for this? - [x] I have searched the existing issues ### Current Behavior Please link the **bold** instruction to **Create a backup of your database** to relevant documentation (add docs if they don't exist) on: https://github.com/juanfont/headscale/blob/main/docs/setup/upgrade.md I found the config in: ```yaml database: sqlite: path: /var/lib/headscale/db.sqlite ``` and copied it to my home directory with: ``` sudo systemctl stop headscale sudo cp /var/lib/headscale/db.sqlite headscale-backup-$(date +%Y%m%d).sqlite ``` ... do upgrade ... ``` sudo systemctl start headscale ``` It consumed 15-20 minutes + frustration + time to write up this issue and switch contexts to figure out how to do this, when a few lines of documentation could have just told me how to do it. My philosophy is that, if we each only help ourselves, we have only one person helping us. But when we help others, we potentially have millions of others helping us. I know which world I would rather live in, but I'm afraid our current society oddly values the former over the latter. 😃 I mean, when we document our own code (I am never offended by documentation that is written to be "fool proof"), we free others' energy so that they can focus on contributing back to our own projects in return. Thank you. ### Expected Behavior I expected a link to docs on how to backup the database. ### Steps To Reproduce Read the docs on how to do an upgrade and find there is no reference on how to backup. ### Environment ```markdown - OS: Debian GNU/Linux 12 (bookworm) - Headscale version: v0.25.1 (I need to upgrade, hence this issue) - Tailscale version: N/A ``` ### Runtime environment - [ ] Headscale is behind a (reverse) proxy - [ ] Headscale runs in a container ### Debug information Not relevant to the issue.
adam added the stalebug labels 2025-12-29 02:27:51 +01:00
adam closed this issue 2025-12-29 02:27:51 +01:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 25, 2025):

This issue is stale because it has been open for 90 days with no activity.

@github-actions[bot] commented on GitHub (Aug 25, 2025): This issue is stale because it has been open for 90 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (Sep 1, 2025):

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions[bot] commented on GitHub (Sep 1, 2025): This issue was closed because it has been inactive for 14 days since being marked as stale.
Author
Owner

@thfi commented on GitHub (Nov 14, 2025):

For anyone looking for an automated solution to backup the database: I addressed backup'ing the database the follow way. As headscale is started and stopped via systemd, add an override configuration that copies the database to another file each time the service is stopped. In the example below, the backup's filename contains the file's MD5 checksum to avoid having multiple copies of the same database and the headscale version number in case there are incompatible changes across versions. File properties like modification dates are kept when copying, allowing to identify old copies that one can delete.

  1. Create the file /etc/systemd/system/headscale.service.d/backup-config.conf as follows:
    [Service]
    ExecStopPost=/usr/bin/bash -c 'cp --verbose --preserve=all /var/lib/headscale/db.sqlite /var/lib/headscale/"$(headscale version|grep -Po --color=NEVER "(?<=v?)[01](\\.[0-9]+)+"|head -n1)"-"$(md5sum <"/var/lib/headscale/db.sqlite"|cut -f1 -d " ")"-db.sqlite'
    
  2. Tell systemd to reload the updated configuration: systemctl daemon-reload
@thfi commented on GitHub (Nov 14, 2025): For anyone looking for an automated solution to backup the database: I addressed backup'ing the database the follow way. As headscale is started and stopped via systemd, add an override configuration that copies the database to another file each time the service is stopped. In the example below, the backup's filename contains the file's MD5 checksum to avoid having multiple copies of the same database and the headscale version number in case there are incompatible changes across versions. File properties like modification dates are kept when copying, allowing to identify old copies that one can delete. 1. Create the file `/etc/systemd/system/headscale.service.d/backup-config.conf` as follows: ``` [Service] ExecStopPost=/usr/bin/bash -c 'cp --verbose --preserve=all /var/lib/headscale/db.sqlite /var/lib/headscale/"$(headscale version|grep -Po --color=NEVER "(?<=v?)[01](\\.[0-9]+)+"|head -n1)"-"$(md5sum <"/var/lib/headscale/db.sqlite"|cut -f1 -d " ")"-db.sqlite' ``` 2. Tell systemd to reload the updated configuration: `systemctl daemon-reload`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1037