webCOMAND

Repository CLI

The following repository functionality is available from the command-line interface (CLI).

  • create - Create a repository
  • init - Initialize a repository
  • delete - Delete a repository
  • snapshot - Take a repository snapshot.
  • restore_snapshot - Restore a repository snapshot.
  • backup - Backup a repository to a file
  • restore - Restore a repository from a backup
  • refresh_cache - Update and rebuild cached information and metadata in the repository
  • diagnose - Check for repository corruptions and repair issues

Create a Repository

comand repo create repo_name

Initialize a Repository

Wipe out existing repository if one exists, including all data, and set up a clean initial core set of content types and objects.

comand repo init repo_name

Delete a Repository

comand repo delete repo_name

Snapshot a Repository

Create a new repository snapshot for the current time, which ensures the current version of all Content in the repository will be maintained until the snapshot is unlocked.

php comand.php io_comand_repo snapshot
Snapshots can be viewed, created and restored from the Repositories App.

Restore a Snapshot

Restore all content to a version captured from a previously created repository snapshot based on the snapshot revision ID and optional content type, where type is a Content Type Identifier with optional '+'.  If the type is not specified, Content+ will be used.

php comand.php io_comand_repo restore_snapshot -i revision_id [-t type]
Snapshots can be viewed, created and restored from the Repositories App.

Backup a Repository

Backup a repository to a file that can be restored with the CLI restore or from the Repositories App.

php comand.php io_comand_repo backup [-f file_path]

If no file path is provided, the configured repository backup folder and filename will be used.

MySQL Dump

As an alternative, backup a MySQL database with mysqldump:

/usr/bin/mysqldump -u user -p --lock-tables=false --max_allowed_packet=64MB webcomand_db > backup_file

As another alternative, if a mysql cnf file is available with login credentials:


/usr/bin/mysqldump --defaults-extra-file=/etc/webcomand.cnf --lock-tables=false --max_allowed_packet=64MB webcomand_db > backup_file

Restore a Repository

Restore a repository from a file created with CLI backup or from the Repositories App.

Options are:

  • --file or -f - File path to backup archive.
  • --test or -t - Run in test mode (without renaming tables).
  • --cleanup or -c - Clean up restore-prefixed tables in the repository from an old failed or test restore process.
  • --force or -o - Forces a restore even when the backed up repo version does not match the current code version.
  • --fast or -a - Skip row/checksum verification of archive data which can add minutes to the restore process for large backups.
php comand.php io_comand_repo restore -f file_path

The file path can be an absolute or relative filename.  If a relative filename is provided, the configured repository backup folder will be used as the base folder.

MySQL Restore

As an alternative, restore a MySQL database dump with:

/usr/bin/mysql -u user -p -e "DROP DATABASE webcomand_db"
/usr/bin/mysql -u user -p -e "CREATE DATABASE webcomand_db CHARACTER SET utf8 COLLATE utf8_general_ci"
/usr/bin/mysql -u user -p webcomand_db < backup.sql

Or, if the MySQL database dump is in a gzip (.sql.gz) file:

gunzip < backup.sql | mysql -u user -p webcomand_db

Or, if you are the root user, you can replace the username and password options with a mysql cnf file:

gunzip < backup.sql | mysql --defaults-extra-file=/etc/my.cnf webcomand_db
When a database is restored from a MySQL dump, you must immediately diagnose the repository to ensure new objects are assigned an appropriate OID, etc.

Refresh Cache

Update and clear repository object caches.

php comand.php io_comand_repo refresh_cache -m [update|clear]
  • -m <mode> - where mode is one of the following
    • update - update missing and out of date repository object method metadata
    • clear - clear and rebuild repository object method metadata
    • update-all - update missing and out of date repository object metadata (fields and methods)
    • clear-all - clear and rebuild repository object metadata (fields and methods)
  • --batch <number> - refresh cache <number> objects at a time, reconnecting to the repository each time to reduce memory requirements.   Default is 1000.  -1 = unlimited.
  • --ct <content type> - Optional Content Type Identifier of objects to update
  • --method <method> - Optional Content Type Method to update from the following list (if not specified, all will be updated)
    • Description
    • Key
    • Keywords
    • Summary

Example

php comand.php io_comand_repo refresh_cache -m update --ct Product --method Summary

Diagnose Repository

Diagnose, cleanup, repair and optimize the repository and underlying databases.

php comand.php io_comand_repo diagnose -m [check|cleanup|repair|optimize]
  • -m mode - where mode is one of the following
    • check - Check the repository and report on any discovered corruptions, but do not repair them.
    • cleanup - Remove old content versions that now fall outside the retention policy defined in Content Settings.  Also remove defunct content history that is no longer locked by a time-based lock, such as the time-based locks in place during a publish.
    • repair - Check the repository, fix and report on any discovered corruptions.  It will automatically repeat the process until there are no more issues, or if it completes three iterations and still has issues.
    • optimize - Optimize the repository by removing unused past revisions and sessions,  updating indexes and defragmenting underlying databases (with OPTIMIZE).
The command-line above should eventually become just:
comand repo [check | cleanup | repair | optimize]
(repo should be a standard CLI Route Alias "installed" with io_comand_repo)