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.
For more details on its development status see http://dev.tiki.org/TRIM.
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.
MultiTiki is an alternative to TRIM.
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)
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.
LGPL, like the rest of Tiki
Here is a brief explanation of the basic commands that can be used. All commands follow a wizard pattern.
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:
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
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
permits to modify an instance which is managed by TRIM. Added on 2017-11-16
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.
When files are altered, added or removed, TRIM will prompt with various solutions.
A synonym of make check
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.
svn up
and thus merging any changes
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.
run:
php scripts/setupupdate.php
Do not pick the same time as automatic backup!
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.
Converts an instance from CVS BRANCH-1-9 to SVN branches/2.0.
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
permits to run any Console command. Added on 2017-11-16
Opens a shell to the remote host. Because TRIM manages all your connections, using this command simply avoids needing to remember passwords.
What can go wrong and how should this script protect me?
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:
Archives are cleaned up after each run. The rules are the following:
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
run:
php scripts/setupbackup.php
Do not pick the same time as automatic update!
You can restore on a blank install. Ref: make blank
If you have data files that are not stored in the database, you should use the ideal scenario for data file storage and relative paths.
Delete the instance via the command line (you could also do via the web interface). This does NOT delete your Tiki. It just deletes the instance connection to it.
Activate the TRIM Web Administration. The script asks a few questions and changes some permissions.
View the SQLite database. For debug purposes.
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.
This is to delete all state (sqlite3 database), backup, cache, and log files. Useful for development.
Makes another identical copy of Tiki. This is basically a combination of make backup and make restore in one operation. You will be asked:
If you have data files that are not stored in the database, you should use the ideal scenario for data file storage and relative paths.
2018-05-02: An issue was noticed with make clone of branch 12.x to 15.x So workaround is to upgrade to 15.x.
Like above but with an extra upgrade operation
[root@trim]# php scripts/clone.php upgrade 1 3 branches/15.x Creating snapshot of: mern.suite.wiki Downloading files locally... Obtaining database dump... Creating archive... ... ...
2018-05-02: An issue was noticed with make clone of branch 12.x to 15.x So workaround is to upgrade to 15.x.
#!/bin/bash PHP="/usr/bin/php -d memory_limit=256M" cd /root/trim || exit 1 $PHP /root/trim/scripts/clone.php clone 1 2 >> /var/log/trim-clone.log 2>&1 $PHP /root/trim/scripts/clone.php upgrade 1 3 tags/15.4 >> /var/log/trim-cloneupgrade-15x.log 2>&1 $PHP /root/trim/scripts/clone.php upgrade 1 4 tags/16.2 >> /var/log/trim-cloneupgrade-16x.log 2>&1 $PHP /root/trim/scripts/clone.php upgrade 1 5 trunk >> /var/log/trim-cloneupgrade-trunk.log 2>&1 exit 0
Explanation:
$PHP /root/trim/scripts/clone.php upgrade 1 3 branches/15.x >> /var/log/trim-cloneupgrade-15x.log 2>&1
This clones instance #1 to #3, and upgrades to 15.x and sends all info to log file
PHP Parse error: syntax error, unexpected '.', expecting ',' or ';' in /var/local/trim/src/rclib.php on line 30
because of the DIRECTORY_SEPARATOR constant usage
ext/ssh2 is not mandatory, but highly recommended to speed up TRIM. It will also avoid many weird error messages and it is much stabler. Without it, it should work but some things may not.
To install it under Debian or Ubuntu:
# sudo apt-get install libssh2-php
If that didn't work:
# sudo apt-get install php5-dev libssh2-1-dev php-pear
# sudo pear install pecl/ssh2-0.11.0
If you get questions, just press "Enter" to accept the defaults.
# sudo nano /etc/php5/cli/php.ini
# php -m
Related
http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/
To install all of these under Debian or Ubuntu
sudo apt-get install make subversion php5-cli sqlite php5-sqlite php5-pspell php5 cron rsync bzip2
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
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
On a Mac, you'll need something like MacPorts. The package names may vary a bit.
sudo port install make sudo port install php5-sqlite3 ...
You may first want to use Tiki Check to see if you server has all the requirements.
The recommended location is /var/local/trim
.
For other servers, this should be in a non-web accessible directory.
svn co https://svn.code.sf.net/p/tikiwiki/code/trim/ .
If you got TRIM before 2012-12-12, you need to:
svn switch --relocate https://tikiwiki.svn.sourceforge.net/svnroot/tikiwiki/trim https://svn.code.sf.net/p/tikiwiki/code/trim/ .
svn up
The first time TRIM is ran, it will complete the setup (e.g. run Composer, set keys, etc.)
make instance
(or just type make and you will get choices available like make check, make update, etc)
If TRIM is not detecting php5-cli (It's important to have at least php-cli version 5.6)
To test:
$ php -v
This should give you the PHP version of your default command line version. Ex.:
PHP 4.4.9 (cli) (built: Sep 17 2008 12:02:18) Copyright (c) 1997-2008 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
If you have more PHP versions available but the default one is lesser than PHP 5.6:
In this case you should manually edit the file Makefile
Replace:
PHP = php -d memory_limit=256M
with something like:
PHP = php56 -d memory_limit=256M
or:
PHP = /usr/local/php5/bin/php -d memory_limit=256M
The 'which php' command does 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
[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
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.
To install necessary software under Debian or Ubuntu:
# sudo apt-get install phpmyadmin ssh
After the install, visit http://localhost/phpmyadmin/
trim@trim:~/avantech-trim$ make instance php5 -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. Connection type [ssh|ftp] : ssh Host name : localhost User : trim Instance name : [localhost] Contact email : Web root : [/home/trim/public_html] /var/www/restoredfromtrim/ Web URL : [http://localhost] http://localhost/restoredfromtrim Working directory : [/home/trim/trim_temp] /tmp Instance information saved. The authenticity of host 'localhost (::1)' can't be established. RSA key fingerprint is <snip>. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'localhost' (RSA) to the list of known hosts. trim@localhost's password: Testing connection... After successfully entering your password, were you asked for a password again? [yes|no] no Detecting remote configuration. No applications were found on remote host. Which one do you want to install? (none to skip) [0] tikiwiki >>> No instance to install. trim@trim:~/avantech-trim$