Automated Backups
How to setup automated backups of the Everdo database.
Overview
To back up the database while the app is running you need to use the sqlite3
tool - the official client for working with SQlite databases.
Setting up automated SQLite backups
- Create a backup script and make it executable.
- Test the script - make sure a backup is created and stored where you expect.
- Schedule the script to run periodically, for example as a cron job or as a scheduled task on Windows.
Here is a simple backup script. You need to replace /home/user
with you unix user directory.
#!/bin/bash
TIMESTAMP=$(date +%F_%T | tr ':' '-')
sqlite3 /home/user/.config/everdo/db ".backup '/home/user/.config/everdo/backups/db_backup_$TIMESTAMP.sqlite'"
A more robust script that will retry the backup command up to 9 times if the first backup attempt fails. Credit to Christian.
#!/bin/bash
counter=0
while [ $counter -lt 9 ]
do
/usr/bin/sqlite3 /home/user/.config/everdo/db ".backup '/home/user/.config/everdo/backups/db_backup_$(date +%F_%T | tr ':' '-').sqlite'"
return_value=$?
if [ $return_value -eq 0 ]; then
counter=9
else
counter=$(( $counter + 1 ))
fi
done
Last modified March 31, 2021