All HowTo's Linux MySQL & MariaDB Synology

Backup vTigerCRM on Synology (MySQL / MariaDB)

Synology include the vTiger CRM suite as a plugin/add-on. They didn’t include a backup solution though. This how-to described how to backup the vTiger CRM database.

The idea is to dump the database regularly, into a place that some other backup process includes. For example, if you have a “Shared Folder” that you “snapshot” and “replicate” elsewhere regularly, then you can simply dump the MySQL (mariadb) database to that location.

This is an “advanced” tutorial. You need SSH access to your Synology. You need a pretty good understanding of Linux to do this. I’ve gone pretty high-level with this one.

Create a script (a file) as “/root/backup-vtigercrm.sh” and put the following into it:

#!/bin/bash

/usr/local/bin/mysqldump -u vtigercrm_user --password='myPassWordForVtiger' vtigercrm > /volume1/Local_backups/vtigercrm/vtigercrm-$(date +%w).sql

Obviously you need to set the username, password and target location according to your setup. But otherwise the script is very simple.

TIP: You can see I’ve use “vtigercrm-$(date +%w).sql” in the script above. This essentially gives us a 7 day retention of the file. In other words, it names the backup by the day of the week, and there are 7 days in a week. This allows us a quick way to restore without having to go to “snapshots” to get the file back. You could replace the “%w” with “%a” for the “short name of the day”, or “%A” for the “long name of the day”.

TIP: If you don’t know your vTiger CRM database credentials, you can get them from the file:

/var/services/web_packages/vtigercrm/config.inc.php

Now we can create a schedule for the backups to run. We can use the Synology “Task Scheduler” for this.

  1. Synology -> Control Panel -> Task Scheduler.
  2. Create -> Scheduled Task, User Defined Script.
  3. General Tab: “Task” = The meaningful name of the task. Such as “vTiger CRM Database Dump”. “User” = “root”.
  4. Schedule Tab: Run Daily.
  5. Task Settings Tab: “User Defined Script” = “bash /root/backup-vtigercrm.sh” without the “” marks.

You can confirm your task is running by checking the target “Shared Folder” once the scheduled task has run.

Leave a Reply

Your email address will not be published. Required fields are marked *