forked from kahst/BirdNET-Lite
-
-
Notifications
You must be signed in to change notification settings - Fork 140
Backup and Restore the Database
Patrick McGuire edited this page Mar 23, 2022
·
11 revisions
The steps I outline here are the recommended backup and restoration methods.
You can very easily create a backup of your database using the "System" > "Tools" > "Database Maintenance" tool.
- To do so, open the "Database Maintenance" tool and connect to the database (i.e., login to Adminer to connect to the database)
- Once connected, click the "Export" link on the left side of the window, which will bring you to the page you see below.
- Choose "
gzip
" as the Output, "SQL
" as the Format, and leave everything else as is. - Finally, click Export and you will begin downloading a copy of your database.
- To restore the backup, you will again use the "Database Maintenance" tool to connect to the database (login to Adminer)
- Once connected, click the "Import" link on the left side of the window, which will bring you to the page you see below
- Click the "Choose Files" button to select the database backup you created (you will see the file name to the right of "Choose Files" after you have selected it).
- Finally, click Execute and you will see that the database has been restored. That's it! You restored the database!
You can also create and restore backups in the command line, though it is not quite as easy as the method above.
- First, ensure you have your database password handy (preferably in the clipboard ready to paste).
- With your database password handy, issue the command below, which will prompt you for the password:
The command above created a backup of the
mysqldump -ubirder -p birds detections > /home/pi/BirdNET-Pi/scripts/detections.sql
detections
table of thebirds
database and placed that file in thescripts
directory. - Use the "System" > "Tools" > "File Manager" tool to navigate to the
scripts
directory and download a copy of thedetections.sql
file.
- Using the "System" > "Tools" > "Database Maintenance" tool, upload the
detections.sql
backup file to thescripts
directory. - In a terminal, change the permissions of the backup so that
pi
owns and can use the backup.sudo chown pi:pi /home/pi/BirdNET-Pi/scripts/detections.sql
- Then restore the backup (the command below will prompt you for your new installation's database password, so don't use the password from the old database).
mysql -ubirder -p birds < /home/pi/BirdNET-Pi/scripts/detections.sql
That's it! You restored the database!