-
-
Notifications
You must be signed in to change notification settings - Fork 510
Backup and Restore
Mycodo can be backed up and restored from the web UI, under the Configure -> Backup Restore page. This is the preferred method for backing up and restoring Mycodo settings and measurement data.
However, if you cannot access this page or prefer to do it from the command line, the following sections will show you how.
sudo /bin/bash ~/Mycodo/mycodo/scripts/upgrade_commands.sh backup-create
sudo /bin/bash ~/Mycodo/mycodo/scripts/upgrade_commands.sh backup-restore <restore_backup>
Replace <restore_backup>
with the backup you would like restored. It must be the full location. Use the following command to see what backups exist.
ls -l /var/Mycodo-backups
Example output
pi@raspberry:~$ ls -l /var/Mycodo-backups
drwxrwxr-x 9 mycodo mycodo 4096 Jun 19 23:33 Mycodo-backup-2017-06-23_02-07-50-5.0.35
drwxrwxr-x 9 mycodo mycodo 4096 Jun 19 23:33 Mycodo-backup-2017-07-06_19-04-27-5.0.41
The full restore command to select the earlier version from this example would be
sudo /bin/bash ~/Mycodo/mycodo/scripts/upgrade_commands.sh backup-restore /var/Mycodo-backups/Mycodo-backup-2017-07-06_19-04-27-5.0.41
/usr/bin/influxd backup -database mycodo_db -portable <path to save backup>
If you are restoring the mycodo influxdb database on a system that has not yet had Mycodo installed but influxdb is installed, you can merely execute the following command.
/usr/bin/influxd restore -portable -newdb mycodo_db <path to influxdb backup>
However, a more likely scenario is you already have Mycodo installed, and in this case, you already have an influxdb database named mycodo_db that you cannot just "add" new data to by executing the restore command. You will need to restore your backed up data to a temporary database, copy the measurements from the temporary database to the mycodo database, then delete the temporary database.
First, restore the backed up data to a temporary database,
/usr/bin/influxd restore -portable -db mycodo_db -newdb mycodo_db_bak <path to influxdb backup>
Next, copy the measurements and delete the temporary database. This may take a while if there's a lot of data.
/usr/bin/influxd
> USE mycodo_db_bak
> SELECT * INTO mycodo_db..:MEASUREMENT FROM /.*/ GROUP BY *
> DROP DATABASE mycodo_db_bak