Backup
Make sure prometheus is running with the flag
If not edit the prometheus server entrypoint and add this flag --web.enable-admin-api
.
Then take a snapshot
Then under prometheus data path defined using --storage.tsdb.path
usually it’s under /var/lib/prometheus
, You will file a directory named snapshots
Mine is empty but you will find a dirs which are hard links to all data blocks dirs.
Backup the dir as tarball, this can take time so it’s better to executed under a terminal screen.
Before you backup make sure that you have enough space to avoid filling up the machine root fs.
Save the prom-bak-.tar.gz
to some reliable storage like S3 or to your local NAS servers.
You can save space after you pushed the archive by deleting the snapshots
directory, and the archive.
Restore
After archiving and transferring the snapshot to the new prometheus, the restore is simple as :
Stopping prometheus service.
Back up old data dir
Extract the content of snapshot to prometheus data dir
Reload prometheus
Or restart prometheus service