1

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.

MacMartin
  • 338
  • 1
  • 4
  • 17

1 Answers1

1

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.

chicks
  • 3,639
  • 10
  • 26
  • 36
  • awesome, thx @chicks - thanks for the links to the documentation - is the documentation on modules.rexify.org more current then https://www.rexify.org/docs/api.html? – MacMartin 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 00: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 – MacMartin Jul 23 '18 at 08:45
  • 1
    workaround: https://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 (https://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. [...]" – MacMartin Jul 23 '18 at 11:15