Regular database backups are essential for protecting your Easy!Appointments installation from data loss due to server crashes, human error, or unexpected issues. Automating this process ensures that you always have a recent copy of your data available without manual effort.
Here’s how you can configure automated database backups for Easy!Appointments:
1. Try the Backup Script
Easy!Appointments already has support for CLI commands that can be triggered from a terminal environment. You can find more info on the available commands by executing the help command.
php index.php console help
In there, you will find that one of the available commands is the backup command, that looks like this.
php index.php console backup
This command will gather and export all the database information inside the storage/backups/ folder on the server, in a gzipped SQL format that can be easily later imported back into a new database.
It is important to make sure that the storage/backups/ folder and contents is not accessible via the web for security reasons.
2. Schedule Automatic Backups with Cron
Set up a cron job to run your backup script at regular intervals (for example, every day at midnight).
Edit your crontab:
crontab -e
Add this line:
0 0 * * * php /path/to/index.php console backup
This will automatically create a backup each night at 12:00 AM.
3. Manage Old Backups
To avoid disk space issues, you can extend your script to delete old backups automatically:
find /path/to/storage/backups -type f -mtime +7 -name "*.gz" -delete
This will remove backups older than 7 days, keeping your backup directory clean and manageable.
4. Store Backups Remotely (Optional)
For extra safety, upload your backups to a remote location such as:
- A cloud storage service (Google Drive, Dropbox, AWS S3, etc.)
- A remote server via
rsync
orscp
This ensures your data remains recoverable even if the server hosting Easy!Appointments is compromised.
5. Test Your Backups
Always test your backups by restoring them to a separate database. This helps verify that your backups are working properly and can be used for recovery when needed.
Going Premium
Did you read this article, but you’re still not sure on how to proceed?
Reach out to info@easyappointments.org and have an expert take care of everything for you in zero time.
Get your free quote and get started now!