InfluxDB : Backup and Restore2024/08/26 |
This is how to back up and restore InfluxDB database. |
|
[1] | Back up a database. |
# backup [test_database] to [/home/influxd_backup] root@dlp:~ # influxd backup -database test_database /home/influxd_backup 2024/08/26 10:12:11 backing up metastore to /home/influxd_backup/meta.00 2024/08/26 10:12:11 backing up db=test_database 2024/08/26 10:12:11 backing up db=test_database rp=autogen shard=3 to /home/influxd_backup/test_database.autogen.00003.00 since 0001-01-01T00:00:00Z 2024/08/26 10:12:11 backup complete: 2024/08/26 10:12:11 /home/influxd_backup/home/influxd_backup/meta.00 2024/08/26 10:12:11 /home/influxd_backup/home/influxd_backup/test_database.autogen.00003.00root@dlp:~ # ls -l /home/influxd_backup total 10 drwx------ 2 root wheel uarch 4 Aug 26 10:12 ./ drwxr-xr-x 5 root wheel uarch 5 Aug 26 10:12 ../ -rw-r--r-- 1 root wheel uarch 486 Aug 26 10:12 meta.00 -rw-r--r-- 1 root wheel uarch 2048 Aug 26 10:12 test_database.autogen.00003.00 # possible to backup specific retention policy or retention duration like follows root@dlp:~ # influxd backup -database test_database -retention one_day -since 2024-08-26T00:00:00Z /home/influxd_backup |
[2] | Restore a Backup database. |
# stop service before restoring root@dlp:~ # service influxd stop
# run restore command # [-metadir] : target directory meta data is restored (follow is the default location) # [-datadir] : target directory database is restored (follow is the default location) # [-database] : target database name restored root@dlp:~ # influxd restore -metadir /var/db/influxdb/meta -datadir /var/db/influxdb/data -database test_database /home/influxd_backup Using metastore snapshot: /home/influxd_backup/meta.00 2024/08/26 10:16:27 Restoring offline from backup /home/influxd_backup/test_database.*
root@dlp:~ #
chown -R influxd:influxd /var/db/influxdb/meta /var/db/influxdb/data root@dlp:~ # service influxd start
# verify resotored data root@dlp:~ # influx -username admin -password adminpassword -database test_database -precision rfc3339 -execute 'select * from weather' name: weather time location temperature ---- -------- ----------- 2024-08-26T01:19:54.407479784Z hiroshima 20 2024-08-26T01:19:57.936094746Z hiroshima 22 2024-08-26T01:20:01.344264152Z osaka 18 2024-08-26T01:20:04.71281686Z osaka 19 |
Sponsored Link |