Support

UNiTE, Remote CLI, eXtract Wizard

#38083 Setting filename as argument

Posted in ‘UNiTE and Remote CLI’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

PHP version
8.0.12
Tool
UNiTE
Tool version
n/a

Latest post by nicholas on Friday, 02 December 2022 07:29 CST

arnaudgautron

Hello, we'd like to set some parameters of unite restoration configuration with CLI arguments rather than in the XML file. For instance,

php unite.phar joomla.xml -env filename=test.jpa

with this, we could define the jpa file at runtime (and to not define it in the xml file)

Is there a way?

Thanks for your help

nicholas
Akeeba Staff
Manager

No, you cannot do that.

Do note that the latest published version of UNiTE does support XML, JSON, and YAML files. Automation tools such as Ansible can work with these file formats.

At the very least, since you are in the command line, you can use text replacements with sed. For example, instead of the JPA filename put in your file the string ##JPA_FILENAME##. You can now set up a Bash script like so

#!/usr/bin/env bash
sed "s/##JPA_FILENAME##/$1/g" /path/to/master.xml `pwd`/temp.xml
php /path/to/unit.phar `pwd`/temp/xml
rm `pwd`/temp/xml

Change the permissions of that shell script to 0700 and you could call it like

$ /path/to/script.sh /some/path/to/backup.jpa

I hope this helps!

PS: The script is off the top of my head and the paths need changing, obviously. Test locally before you deploy.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

arnaudgautron

Thanks for your answer. Sure it helps.
Your solution using sed was pretty much the answer our developer had found.

nicholas
Akeeba Staff
Manager

You're welcome!

Using sed to modify a template configuration file is a staple for sysadmins :) Every one, from the greenest junior to the gray-bearded senior knows how to do that. That's why I kept the XML file support and also added YAML support β€” the latter is typically much easier to work with search and replace using sed, with newer sysadmins being very familiar with it.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!