@cryptotaxi247 / netdata-1 / commits / 57ffef0c9

Netdata Agent: Backup restore documentation (#17006)

A document on how to backup and restore the Netdata agent for the public docs. This works in a test environment and I've used it once in production so please check it over as it may need ammendments. --------- Co-authored-by: Fotis Voutsas <fotis@netdata.cloud>

Luis Johnstone committed Feb 28, 2024 at 16:02 UTC 57ffef0c92c479a0bb5e48c87c90c31d660d8049
1 file changed +66
docs/maintenance/backup-restore.md new
+66
@@ -0,0 +1,66 @@
1 +# Backing up a Netdata Agent
2 +
3 +## Introduction
4 +
5 +When preparing to backup a Netdata Agent it is worth considering that there are different kinds of data that you may wish to backup independently or all together:
6 +
7 +| Data type | Description | Location |
8 +|---------------------|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
9 +| Agent configuration | Files controlling configuration of the Netdata Agent | [config directory](https://github.com/netdata/netdata/blob/master/docs/netdata-agent/configuration.md) |
10 +| Metrics | Database files | /var/cache/netdata |
11 +| Identity | Claim token, API key and some other files | /var/lib/netdata |
12 +
13 +
14 +## Scenarios
15 +
16 +### Backing up to restore data in case of a node failure
17 +
18 +In this standard scenario you are backing up your Netdata Agent in case of a node failure or data corruption so that the metrics and the configuration can be recovered. The purpose is not to backup/restore the application itself.
19 +
20 +1. Verify that the directory-paths in the table above contain the information you expect.
21 +
22 + > **Note**
23 + > The specific paths may vary depending upon installation method, Operating System and whether it is a Docker/Kubernetes deployment.
24 +
25 +2. It is recommended that you [stop the Netdata Agent](https://github.com/netdata/netdata/blob/master/docs/configure/start-stop-restart.md) when backing up the Metrics/database files.
26 + Backing up the Agent configuration and Identity folders is straight-forward as they should not be changing very frequently.
27 +
28 +3. Using a backup tool such as `tar` you will need to run the backup as _root_ or as the _netdata_ user in order to access all the files in the directories.
29 +
30 + ```
31 + sudo tar -cvpzf netdata_backup.tar.gz /etc/netdata/ /var/cache/netdata /var/lib/netdata
32 + ```
33 +
34 + Stopping the Netdata agent is mostly required in order to back up the _database files_ of the Netdata Agent.
35 +
36 + If you wish to minimize the gap in metrics caused by stopping the Netdata Agent, then you could have a backup job or script that uses the following sequence:
37 +
38 +- Backup the Agent configuration Identity directories
39 +- Stop the Netdata service
40 +- Backup up up the database files
41 +- Restart the netdata agent.
42 +
43 +### Restoring Netdata
44 +
45 +1. Ensure that the Netdata agent is installed and is [stopped](https://github.com/netdata/netdata/blob/master/packaging/installer/README.md#maintaining-a-netdata-agent-installation)
46 +
47 + If you plan to deploy the Agent and restore a backup on top of it, then you might find it helpful to use the [`--dont-start-it`](https://github.com/netdata/netdata/blob/master/packaging/installer/methods/kickstart.md#other-options) option upon installation.
48 +
49 + ```
50 + wget -O /tmp/netdata-kickstart.sh https://get.netdata.cloud/kickstart.sh && sh /tmp/netdata-kickstart.sh --dont-start-it
51 + ```
52 +
53 + > **Note**
54 + > If you are going to restore the database files then you should first ensure that the Metrics directory is empty.
55 + >
56 + > ```
57 + > sudo rm -Rf /var/cache/netdata
58 + > ```
59 +
60 +2. Restore the backup from the archive
61 +
62 + ```
63 + sudo tar -xvpzf /path/to/netdata_backup.tar.gz -C /
64 + ```
65 +
66 +3. [Start the Netdata agent](https://github.com/netdata/netdata/blob/master/packaging/installer/README.md#maintaining-a-netdata-agent-installation)