How do I backup files when making a change with rex cm (rexify.org) - or do I have to do this manually?

I see no option in the File.pm API - description. I hope there is some undocumented feature.

Background: It's mostly about the initial configuration. If I push a file, I want to make sure, that potential individual changes are saved somewhere.


The release notes for rex version 0.44 mention:

Rex::Ext::Backup - a simple backup module. This module creates a backup of a file before rex changes it.

include qw/Rex::Ext::Backup/;

set backup_location => "backup/%h";

task yourtask => sub {
   file "/etc/foo.conf", content => "new content\n";

Here are the docs for the module. Google doesn't see them, probably because of the expired SSL certificate. But there is a bit more info there:

You can use the following modifiers for your backup_location.

  • %h - the hostname
  • %t - the time (epoch seconds)

If this doesn't work I'd reach out the the rexify folks directly.

  • awesome, thx @chicks - thanks for the links to the documentation - is the documentation on modules.rexify.org more current then rexify.org/docs/api.html? – eli Jul 22 '18 at 18:43
  • I don't think one is more up-to-date than the other necessarily. The modules.rexify.org site seems to be the place for extensions aka modules which are not in the core documentation on rexify.org itself or other CPAN viewers like metacpan. – chicks Jul 23 '18 at 0:47
  • thanks for the explanation @chicks - somehow the rexify --use=Rex::Ext::Backup command does not work "error malformed JSON string..." but nevermind, I will contact the developers like you suggested. Could you please be so kind to tag tag the questiong wih [rex] if appropriate – eli Jul 23 '18 at 8:45
  • 1
    workaround: groups.google.com/forum/#!topic/rex-users/794tvV45OxY quote: "[...] For those of you who find this post and need a workaround in order to load the dependencies your Rexfiles are asking for, if you clone the rex-recipes repo (github.com/RexOps/rex-recipes) directly, you can copy the modules your Rexfile needs into a lib/ directory in the same directory as your Rexfile, and everything will be happy again. [...]" – eli Jul 23 '18 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.