Structures

The "Tiki Remote Instance Manager (TRIM)" will go into maintenance mode, and the code will be forked and revamped to become its replacement, now known as the "Tiki Manager".

TRIM is an acronym for the Tiki Remote Instance Manager

TRIM is installed on a master server. TRIM then connects to various servers and permits you to manage various instances of Tiki. You can install, upgrade, backup, check the file integrity and do various other things. Some actions can be run unattended on a cron job.

It is not a script to update your Linux or MySQL installation (but it may one day do some server checks to see if your Apache, PHP, MySQL, GD, etc. versions are OK).

Originally developed for Tiki, it was designed so it could be ported/used for just about any PHP / MySQL application which has SVN as a source. If you want to port to a different app, let's work together!

How it works

TRIM is installed on a master server. TRIM then connects by SSH (and more recently via FTP) to various servers. Via a wizard (you answer the questions interactively) TRIM permits you to manage various instances of Tiki. You can install, upgrade, backup, check the file integrity and do various other things. Some actions can be run unattended on a cron job.

Limitations

FTP support has been added, however, you can run into memory limitations (outside of TRIM's control)

About supported versions

In theory, TRIM works for all versions of Tiki, and on all versions of GNU/Linux. In practice the most testing happens for:

Alternatives

MultiTiki: all files (php/tpl/etc) are shared amongst several domain names (but you can have .css and .tpl which override for your domain) but each domain has a distinct database.

TRIM: each domain is totally independent. Distinct database and distinct files and can be on different hosts.

As of 2017-01, TRIM can not be used to manage a Multi-Tiki, but this could be developed (please do get in touch if you have a use case for this)

Similarities

Both TRIM and MultiTiki are tools to facilitate mangement of a large number of Tiki instances,

Advantages of TRIM vs MultiTiki

With TRIM, each instance can be on totally different servers or on various directories on the same server, so you can easily scale to as few or as many servers as you want.

Once an instance is in a MultiTiki, it's a little tricky to extract it. For example, it's easier to provide a backup of just one instance, using TRIM.

If you have multiple domains and need to provide distinct access for each (emails, FTP accounts, access to logs, etc.), it can be easier to have distinct server space.

With MultiTiki, if you have a security issue, all your Tikis are potentially compromised because they share the same files. (even for the Tikis that have not enabled the unsafe feature)

With TRIM, you can pick & choose which Tikis to upgrade. With MultiTiki, all the instances get the upgrade. Even if they don't need the bug fixes or enhancements, they are still at risk of being affected by a regression. So all instances need to be checked after each upgrade.

This takes a lot of time. And then, you can introduce issues for projects that were quite happy with the previous version. They didn't need new stuff, but inherited some problems.

With TRIM, you can modify the templates/*.tpl files and still use the merging features of svn to take advantage of the enhancements to the main code base (There could be conflicts to manually resolve during upgrades though). Using multiTiki, you must put all changes in a separate directory and can't easily benefit from improvements to the main code base.

TRIM handles offsite backups

Advantages of MultiTiki vs TRIM

Uses less disk space

Can upgrade hundreds of Tikis in one operation (whereas TRIM connects one by one to upgrade)

MultiTiki is part of the main Tiki code base whereas TRIM is maintained separately.

TRIM requires SSH access TRIM can now work via FTP, whereas maybe MultiTiki can be run just with FTP. Depending on your server, you may have a lot of permissions to change by FTP though.

TRIM requires more things on the server (sqlite, SVN, etc) not anymore, you can use FTP mode and heavy work is done on TRIM master, and result is pushed to the TRIM instance.

MultiTiki has a web-based interface TRIM Web Administration was added

What if I want to share data between instances?

Sharing data between Tiki instance is not specific to TRIM. If you want to share logins, groups and preferences throughout many Tiki sites, you can use InterTiki.

License

LGPL, like the rest of Tiki

Documentation

Here is a brief explanation of the basic commands that can be used. All commands follow a wizard pattern.

make instance

make instance adds an instance to be managed by TRIM, which can mean either:

When running make instance, TRIM attempts to perform various operations from this point:

Share an RSA key to connect to the remote host in the future

Make a few verifications on remote host

Detect the application installed remotely and the version

If nothing is installed, propose to install something

You will be prompted to enter a pass phrase. If you enter one, you will be prompted every time you use TRIM. Unattended backups and security checks will not be possible.

You have three options for the location of your instance

ftp: another server via FTP access

ssh: another server via SSH access

local: same server

The installation process will ask to create a database and user for Tiki. To do this, root access on the MySQL database (or user with similar privileges) is required. Otherwise, database settings can be entered manually (The database needs to have been created before in cPanel, webmin or similar).

make editinstance

make editinstance permits to modify an instance which is managed by TRIM. Added on 2017-11-16

make blank

Like make instance but it doesn't actually add a Tiki. It just creates and instance than can be restored to or cloned to. Alternatively, you do make instance but cancel when TRIM offers you to install Tiki.

make check

This is somewhat equivalent to a secdb check, except that it's safer because it's made from a trusted host and will take your custom modifications on host into consideration. Upon first run, the check will ask where it should fetch the hashes from.

source : obtain the hashes from the official repository. After setting up the expected hashes, a check will be performed.

current : use the files currently online as the source of hashes. If this is a recent install, this may be safe. However, if the host was already compromised, hacks will be undetected.

skip : Move on for now

When files are altered, added or removed, TRIM will prompt with various solutions.

For modified files, it will allow to view the changes that were made and propose to accept or reject them. Rejecting changes will fetch a copy of the file from the repository.

For added files, it will be possible view the file and then accept or reject it. Rejecting the file will remove it from the remote host.

Removed files will allow to accept or reject the removal. Rejection will fetch a copy from the repository.

make verify

make watch

Set-up a cron job on the TRIM master to perform the Hash check (make check) automatically every day. The script will prompt for a contact email address to notify with the log in the case of a suspicious file change (which could be an intrusion or someone who legitimately changed a file on the server) and the time at which the script should run.

make update

Does a dry-run first, and aborts on any conflicts

Updates to latest code in that branch (or trunk) using svn up and thus merging any changes

And all operations should be done after updating the code

Updates the file hashes accordingly. The hash verification/update may prompt with some files containing conflicts if modifications were made on the instance.

Performs the database update.

Runs setup and Composer,

Clears cache

Rebuilds search index

During the update process, the instance is disabled using a .htaccess file (previous one is preserved), making the site unavailable until the update is completed.

To setup automated updates

run:

php scripts/setupupdate.php

Do not pick the same time as automatic backup!

make upgrade

Similar to update. Requests for the branch to switch to over the update. You will have several choices of branches. Please note that you should NOT downgrade as Tiki doesn't support a downgrade database script. An upgrade is a one-way street! You should make a backup before you upgrade so you can return to this version if issues arise.

If you choose to do a manual upgrade (with svn switch), run a make detect after so TRIM knows about it.

make convert

Converts an instance from CVS BRANCH-1-9 to SVN branches/2.0.

All script customizations will be lost

Database, img/wiki and img/wiki_up are preserved

make fix

Run setup.sh on the remote host using automated parameters. It should work in most cases. If the command proposed my setup.sh without parameters or super user rights are required, you should connect to the remote host manually using `make access`.

make cli

make access

Opens a shell to the remote host. Because TRIM manages all your connections, using this command simply avoids needing to remember passwords.

make backup

What can go wrong and how should this script protect me?

My host disappears

A vandal messes up my files

User error (oups, I erased some files)

TRIM performs a complete backup of the Tiki instance. The backup includes all files (using rsync for efficient bandwidth management) on remote host (including user files and files stored out of the web root) and a dump of the database. Each backup is archived in the TRIM_ROOT/backup/archive folder as a .tar.bz2 file. The backup file contains:

manifest.txt: Indicates where folders were located on the remote host

database_dump.sql: Self-explanatory

[a-f0-9]{32}: Folders named using a hash. Content of the folders on remote host. The manifest.txt file lists these hashes.

Archives are cleaned up after each run. The rules are the following:

Backups made on the first of any month are kept forever.

Backups made on Sunday are kept for 31 days.

Daily backups are kept for a week.

On your first backup, you may get a harmless error message

rm: cannot remove `/home/trim/xyz/backup/1/manifest.txt': No such file or directory

make report

make copysshkey

make detect

Detect Tiki branch or tag, and PHP version. For debugging purposes. Also useful if you manually proceeded to svn switch and TRIM needs to update its internal database about a Tiki instance.

make clean

This is to delete all state (sqlite3 database), backup, cache, and log files. Useful for development.

make clone

Makes another identical copy of Tiki. This is basically a combination of make backup and make restore in one operation. You will be asked:

Select the source instance:

Select the destination instance -> Be very careful as the data here will be wiped and replaced by the data from the source instance This destination instance must exist with a database. It can't be blank.

Requirements

As of 2016-04-15, PHP 5.3 seems to be sufficient for all operations (but of course, you need PHP 5.5 to install Tiki 13.x on remote server)

PHP Command Line Interface (PHP-CLI) on both master and remote servers

Shell (SSH) access on master and remote (remote servers with only FTP will work but with fewer features and slower management)

Both master and instances can be shared hosting as long as you have SSH access. It is recommended that the master be installed on a very safe machine because it has SSH access keys to all your instances.

Linux

If you don't have postfix or sendmail installed already, then you can install at least sendmail. But beware that if you have postfix installed and configured for a custom setup in your server, and you run the command to install sendmail, you will have your postfix automatically removed from your server before sendmail is installed :

sudo apt-get install sendmail

Windows

There are no current plans for TRIM (the master) to work natively on Windows (but you are welcome to join the community and make this happen!) but it works on Cygwin. So you should use something one of options below. The remote host can be a Windows instance however as TRIM supports FTP. Related: Platform independence

The 'which php' command doesn't provide you with the info. If not, ask your host

Question

note

Instance name

Just a pretty name for the Tiki instance

Contact email

Email of person in charge of this Tiki instance

Web root

full path, no trailing slash (/)

Web URL

full URL, with http

Working directory

You can use /tmp or create/use a directory on your remote server. Full path, no trailing slash (/)

SSH host name

domain to connect by SSH

SSH port

if you are not using the usual port 22

SSH user

username to connect by SSH

When make instance reports:
Branch tags/1.10.0 was found. If this is not correct, enter the one to use :
type: branches/1.10

Example

example

[avantech]$ make instance
/usr/local/php5/bin/php -d memory_limit=256M scripts/addinstance.php
Default editor used (vim). You can change the EDITOR environment variable.
Default diff used (diff). You can change the DIFF environment variable.
Instance name : RTO test
Contact email : <hidden>
Web root : /home/rto/public_html
Web URL : http://rto.ourwiki.net
Working directory : /home/rto/temptrim
Instance information saved.
SSH host name : rto.ourwiki.net
SSH user : rto
The authenticity of host 'rto.ourwiki.net (<snip>)' can't be established.
RSA key fingerprint is <snip>.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'rto.ourwiki.net,<snip>' (RSA) to the list of known hosts.
rto@rto.ourwiki.net's password:
Testing connection...
Were you asked for a password? [yes|no] no
warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old
Branch tags/1.10.0 was found. If this is not correct, enter the one to use : branches/1.10

To restore backups on TRIM machines

We want to test that the backups are indeed working so we need a fully functioning php-mysql environment. By installing phpMyAdmin, we should get this. We also want SSH because TRIM connects via SSH to restore these backups, the same as it would connect anywhere.