-
Notifications
You must be signed in to change notification settings - Fork 2
Database Backup
One of the most common things you should do with your Rivendell installation is backing the SQL database regularly. If you're making daily changes to your Rivendell Library we recommend doing a daily backup to both local and cloud storage. In this guide we'll show you how to do a local, as well as setting a systemd service and timer to automate the process daily.
Let's start by creating a folder in your home directory called database_backup. We'll be storing daily database backups in this directory and changing into it.
mkdir database_backup
cd database_backup
Next we need to create a bash script that will backup your database locally. This will open a new text file in the nano editor.
nano databasebackup.sh
Copy and paste the below script into the terminal window. In this script we've assumed your username is pi. If you're using a different user make sure you change it otherwise the script will fail.
#!/bin/bash
# Rivendell Database Backup Script
echo Backing Up The Rivendell Database
echo Please Wait...
su - pi -c "mysqldump -u rduser -h localhost Rivendell > /home/pi/database_backup/RIVENDELL-$(date +%F).sql"
echo All Done
Now we must make the script executable. To do this we'll use the chmod command.
chmod +x database_backup.sh
Now we can run the script using the following command in the terminal.
./database_backup.sh
After the script has done its thing, you should have a .sql file in your database_backup directory named RIVENDELL with today's date following.