I want to create a directory with rex
if it doesn't exist. I read this but I can't find how to do it.
If I send the file without the directory I get this error:
ERROR - upload: /usr/local/path/file.ext is not writable
Any hints?
I want to create a directory with rex
if it doesn't exist. I read this but I can't find how to do it.
If I send the file without the directory I get this error:
ERROR - upload: /usr/local/path/file.ext is not writable
Any hints?
I think the documentation in the rex book is a little older.
Please take a look here https://www.rexify.org/docs/api/ or (as of today) the most current docs here:
https://www.rexify.org/docs/api/1.4/rex/commands/file.pm.html#file-file_name-options-
(it says version 1.4 while the current cpan version is 1.6, but nevermind)
So, to answer your question with an example:
task "backuptask", group => "mygroup", sub {
#
# 1.) define the Backup Dir (you could do it without this step)
my $backupdir = "/tmp/backup";
#
# 2.) "ensure" that the file is a (existing) "directory"
file $backupdir,
ensure=> "directory",
owner => "myowner",
group => "mygroup",
mode => 700,
on_change => sub { say "File was changed";};
#
# 3.) define Backup File
my $currTimestamp = strftime('%y%m%d',localtime);
my $backupfile = "$backupdir/somebackup$currTimestamp";
#
# 4.) "ensure" the the file is "present" at the defined path
file $backupfile, ensure=> "present";
...execute something here...
} ;