Skip to content

maximerauch/glpi-update

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 GLPI Upgrade CLI

Python Platform License

A robust, zero-dependency Python CLI tool designed to automate and secure the upgrade process of GLPI instances.

💡 The Problem

Even with modern versions like GLPI 10+, the official upgrade process remains entirely manual. As detailed in technical documentation (e.g., IT-Connect), administrators must manually:

  1. Download and unzip archives.
  2. Identify and backup specific configuration folders (config, files, plugins...).
  3. Delete old system files (to prevent "ghost" PHP files).
  4. Move the new files.
  5. Restore the configuration folders one by one.
  6. Fix file permissions (chown/chmod).

This manual workflow is error-prone, time-consuming, and stressful in production environments.

✅ The Solution: "Safe Swap"

This tool automates the entire workflow using a "Safe Swap" strategy to ensure production integrity:

  1. Download: Fetches the specific release directly from GitHub.
  2. Atomic Backup: The current production folder is renamed instead of being overwritten.
  3. Clean Install: The new version is extracted into a fresh directory.
  4. Surgical Restore: Critical data folders are automatically copied from the backup to the new instance.
  5. Permissions: Automatically reapplies web-server ownership (chown).

📋 Prerequisites

  • OS: Linux (Debian/Ubuntu/RHEL/CentOS)
  • Python: 3.6 or higher (Standard library only, no pip dependencies required).
  • Privileges: root or sudo access (required to manipulate /var/www).

🚀 Usage

Installation

Clone this repository on your GLPI server:

git clone https://github.com/maximerauch/glpi-update.git
cd glpi-update
chmod +x glpi_upgrade.py

Running an Upgrade

The basic syntax only requires the target version number. The script defaults to /var/www/html/glpi.

# Upgrade to version 10.0.10
sudo ./glpi_upgrade.py 10.0.10

Advanced Options

You can specify custom paths or users if your installation differs from the standard layout:

# Example for a custom path with Nginx user
sudo ./glpi_upgrade.py 10.0.11 \
  --path /opt/glpi \
  --owner nginx \
  --group nginx
Argument Description Default
version Required. Target GLPI version (e.g., 10.0.10). -
--path Absolute path to the GLPI installation. /var/www/html/glpi
--owner System user owning the files. www-data
--group System group owning the files. www-data

⚠️ Post-Script Actions

This script manages file system operations. It does not touch the database to prevent unintended corruption. Once the script completes successfully, you must trigger the database migration:

  1. Go to the GLPI directory:
    cd /var/www/html/glpi
  2. Run the GLPI console migration command:
    php bin/console db:update
    (Alternatively, log in to the web interface to trigger the wizard).

📸 Demo Output

Here is what a successful execution looks like:

$ sudo ./glpi_upgrade.py 10.0.10

[INFO] Target path: /var/www/html/glpi
[INFO] Downloading GLPI 10.0.10 from GitHub...
[SUCCESS] Download complete.
[INFO] Backing up current instance to: /var/www/html/glpi_backup_20251012_143000
[INFO] Extracting new version...
[SUCCESS] New version extracted.
[INFO] Restoring configuration and data files...
 -> Restored: config
 -> Restored: files
 -> Restored: plugins
 -> Restored: marketplace
 -> Restored: certs
[INFO] Applying permissions (Owner: www-data:www-data)...
[SUCCESS] Permissions fixed.

===================================================
[SUCCESS] File system upgrade to 10.0.10 complete!
===================================================

IMPORTANT NEXT STEPS:
1. Database Migration is REQUIRED.
   Run this command now:
   php /var/www/html/glpi/bin/console db:update

2. A backup of the old version is available at:
   /var/www/html/glpi_backup_20251012_143000

🤝 Contributing

Contributions are welcome! Feel free to open an Issue or Pull Request to suggest improvements (e.g., automatic rollback on failure, Slack notifications, etc.).

About

A zero-dependency Python CLI to safely automate GLPI upgrades using a "Backup & Swap" strategy

Topics

Resources

License

Stars

Watchers

Forks

Languages