Use case: I have some Tiki instances on ClearOS and I want automatic backups of different Tiki instances to various local computers for safekeeping. These are high level instructions as to how to combine TRIM and Syncthing to do so. For a hosting company and its customer, this is the optimal solution: This permits a customer to delegate the hosting / management of an application while obtain automatic backups of their application and data.
At a high level:
TRIM (installed on the same server) will make incremental and automated backups of each site to a distinct folder
Syncthing will securely copy each folder to one or many devices.
Incremental while being somewhat efficient for disk spaceThis could be improved quite a bit. Volunteers welcome! : TRIM has a retention cycle: keep last 7 days, last 4 weeks and once per month forever
Remote backup to any number of devices: Syncthing is designed for peer-to-backups
Managed via a web interface (Syncthing)
Web interface can be protected by 2-factor authentication (in addition to password)
Data is encrypted in transport by Syncthing
Cross-platform: Syncthing supports GNU/Linux, Windows, OSX, Android, *BSD, Solaris
We will use the PIPE from the Linux bash in order to inject the desired number. In this case, it is the number 3.
[root@trimclient trim]# echo 3 | make backup
bash scripts/backup.sh php -d memory_limit=256M
php
which: no cpulimit in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
dont use cpulimit
Default editor used (nano). You can change the EDITOR environment variable.
Default diff used (diff). You can change the DIFF environment variable.
Note: Backups are only available on SSH instances.
Which instances do you want to backup?
[2] vv.wikisuite.org m@example.org
[3] ii.wikisuite.org your@example.org
Performing backup for ii.wikisuite.org
Downloading files locally.
RSYNC Return var: 0
Obtaining database dump.
Creating archive.
Return var: 0
As you see, no human interaction was needed.
You may want to install this in a cronjob, to do it every day at noon, do the following.
You can install many instances of Syncthing, but there is not yet a good way to segment permissions. So it's better to create one master Syncthing user. Ex.: tikisyncthingbackup and manage all the backups from that account. Do not give that passwords to customers.
The root user doesn't have an instance of Syncthing. So you need to create a distinct user and provide the right to run Syncthing. And this user must have access to the files and folders you want to sync.
Make sure Syncthing automatically restarts when you reboot so that you have unattended automatic backups. Just reboot to see if it's OK. If not, you need to look up the documentation for your Operating System.
Configuring Syncthing for your Tiki archive folder
You archives will be in something like /var/local/trim/backup/archive/1-example.org/: so sync that folder with your local computer.
Setting up Syncthing for backups
Syncthing by default is set to sync multiple folders so they get to the exact same set of files and folders. So if you delete a file in one folder, the deletion is propagated. In the contexts of backups, this could cause issues. Examples:
Ransomware on any device: Then, all the devices would receive the corrupted data which replaces the valid data.
One of the devices runs out of space, and its user decides to clear out old backups.
The solution is:
On the device sending the backups: set Folder Type to "Send Only"
On the device(s) receiving the backups: set File Versioning. Recommended setting is "Staggered"
Because the master server is set to "Send Only", there is no point in setting to "Staggered" (It doesn't receive any data, and thus doesn't need versioning).
Troubleshooting
If sync is not working as expect, check the Syncthing folder interface for errors.