Utilizing Version Control
Git Integration
myDBR includes Git integration that lets admin users commit changes to database objects (procedures, functions, views) directly from the SQL editor, and to templates from the template editor. Each save creates a versioned snapshot with the committer's name, email, subject, and optional description, giving you a full audit trail of who changed what and when.
Commit All lets you commit all uncommitted changes to Git in a single operation, useful for bulk updates or initial setup. It can be triggered manually from the admin interface or run automatically as a scheduled task via cron.
Once changes are committed locally, you can push them to a remote Git repository. Remote push can be triggered manually or as part of the same scheduled cron job, keeping your remote repository in sync with the local commits.
How it works
SQL and Template editors
When editing objects in SQL Editor or a template, admin users gain additional toolbar buttons:
- Commit - opens a dialog to enter a subject and optional description, then saves the current editor content as a new Git commit

- Git History - opens a table of previous commits

- Git History → view/divv - See changes in an intuitive side-by-side diff view

Environment Settings
The Git section of Environment Settings provides two batch operations that operate across the entire repository:
- Commit All - opens the same commit dialog and then commits every tracked object (reports, procedures, functions, views, and templates) in a single batch. A progress bar shows each object as it is processed. Objects that have not changed since their last commit are skipped automatically.
- Push (optional) - pushes all local commits to the configured remote repository. Only visible when Git Push enabled is checked in the same settings section.
- Scheduled Commit All - a lightweight HTTP endpoint (
gitcron.php) that performs the same commit-all operation in a single synchronous request, designed to be called from a cron job viawgetwithout a browser session. See Scheduled Commit All for setup instructions.
Storage Structure
Objects are stored as plain text files inside a server-side Git repository. All objects, including templates, are organised under the database name first, then by object category:
/var/mydbr/git/
mydbr/ ← Database name
reports/ ← myDBR report procedures (name starts with sp_DBR_)
sp_DBR_Sales.sql
functions/ ← Database functions
fn_TaxCalculation.sql
views/ ← Database views
vw_TotalSales.sql
procedures/ ← Other stored procedures (not reports)
sp_UpdateInventory.sql
templates/ ← myDBR templates
Standard_Email.txt
Invoice_Layout.txt
Templates note: Since templates consist of three distinct parts (Header, Row, and Footer), myDBR combines them into a single .txt file using internal separators (-- header --, -- row --, -- footer --). When you restore a historical version of a template, all three parts are updated simultaneously in the editor. A warning is shown before restoration as this will replace your current content of the tabs.
Stored Objects Categories
No Git account is required for users. Commits use the --author flag populated from the user's session (user_name / user_email), so the full history is attributable without any Git credentials on the server.
Category rules
For database objects, the report prefix is always checked first, before inspecting the SQL source.
| Priority | Category | Condition | Extension |
|---|---|---|---|
| 1 | reports | Object name starts with the myDBR report prefix (default sp_DBR_) | .sql |
| 2 | procedures | SQL source contains CREATE PROCEDURE | .sql |
| 3 | functions | SQL source contains CREATE FUNCTION | .sql |
| 4 | views | SQL source contains CREATE VIEW | .sql |
| 5 | templates | Edited via the Template Editor | .txt |
Prerequisites
1. Git must be installed
git --version
Install if missing:
## Debian / Ubuntu
sudo apt install git
## RHEL / AlmaLinux / CentOS
sudo dnf install git
Verify that the PHP process user can run the binary:
sudo -u www-data git --version
If the command fails even though which git succeeds, the PHP environment has a restricted PATH. The simplest fix is to use the full binary path in the configuration (Step 4).
2. PHP exec() must enabled
php -r "echo ini_get('disable_functions');"
exec must not appear in the output. If it does, remove it from disable_functions in php.ini and restart the web server.
Setup
Step 1 - Find your PHP process user
All subsequent steps require you to substitute the correct system user that runs the PHP process. In many environments (like Nginx with PHP-FPM), the web server user (nginx) and the PHP process user (www-data or php-fpm) are different. The Git repository must be writable by the PHP process user.
Linux
The quickest way is to ask PHP itself, since it is already running under the right user:
## Create a temporary PHP file in the webroot
echo '<?php echo shell_exec("whoami"); ?>' > /var/www/html/whoami.php
## Open it in a browser or fetch it with wget
wget -q -O - http://localhost/whoami.php
## Remove it immediately after
rm /var/www/html/whoami.php
Alternatively, check which user the PHP-FPM or web server process is running as:
## PHP-FPM (most common for Nginx)
ps aux | grep php-fpm | grep -v root | head -1 | awk '{print $1}'
## Apache
ps aux | grep -E 'apache2|httpd' | grep -v root | head -1 | awk '{print $1}'
Common values: www-data (Debian/Ubuntu), apache or httpd (RHEL/AlmaLinux/CentOS), nginx, php-fpm.
Windows (IIS)
PHP under IIS runs as the IIS application pool identity. To find it:
- Open IIS Manager → Application Pools
- Click the pool your myDBR site uses → Advanced Settings
- The value under Identity is the account (typically
IIS AppPool\DefaultAppPoolor a custom service account)
To confirm from the command line, open a PHP file in the browser:
<?php echo shell_exec('whoami'); ?>
The output will be the exact Windows account name (e.g. iis apppool\mydbr). Use this account when setting directory permissions with icacls:
icacls "C:\mydbr\git" /grant "IIS AppPool\DefaultAppPool:(OI)(CI)F" /T
macOS (development / local server)
For the built-in Apache (/usr/sbin/httpd) and most Homebrew setups the web server runs as the current user. Confirm with:
ps aux | grep httpd | grep -v root | head -1 | awk '{print $1}'
Or drop a temporary PHP file into the document root:
echo '<?php echo shell_exec("whoami"); ?>' > ~/Sites/whoami.php
wget -q -O - http://localhost/~$(whoami)/whoami.php
rm ~/Sites/whoami.php
Step 2 - Create the repository directory
Choose a location outside the webroot. The default is /var/mydbr/git.
sudo mkdir -p /var/mydbr/git
sudo chown www-data:www-data /var/mydbr/git
sudo chmod 750 /var/mydbr/git
Replace www-data with the PHP process user identified in Step 1.
No manual
git initneeded. myDBR automatically initialises the repository (runsgit init, sets a default committer identity, and creates an.htaccessguard file) the first time a commit is made. You only need the directory to exist and be writable by the PHP process user.
Attribution and User Profiles
For accurate history, ensure that myDBR users have their Name and Email defined in their user profile (or passed via SSO).
myDBR resolves the Git author in this order:
- Full Name and Email from the user's settings..
- If email is missing, it falls back to the
username@localhost.
Synchronising with Remote Repositories (optional)
The integration performs all operations on the local server repository. To sync your changes to a remote git servers like your own, GitHub, GitLab, or Bitbucket, you must configure a remote and an authentication method on the server.
1. Authentication Options
Option A: SSH (Recommended)
SSH is the most secure method for automated syncing as it uses key-based authentication.
- Generate an SSH key for your PHP process user (e.g.,
www-data):sudo -u www-data ssh-keygen -t ed25519 -C "mydbr-git-sync" - Add the public key to your remote Git service. The key is typically found at:
/var/www/.ssh/id_ed25519.pub(the path depends on the user's home directory). - Test the connection:
sudo -u www-data ssh -T git@github.com
Option B: HTTPS with Personal Access Token
Use this if SSH is restricted in your environment. Do not use your account password; use a Personal Access Token (PAT).
- Generate a PAT with
repo(write) permissions in your Git provider's settings. - Add the remote using the token in the URL:
sudo -u www-data git -C /var/mydbr/git remote add origin https://<username>:<token>@github.com/your-org/your-repo.git