Forum: CFEngine Help
Subject: Re: How does edit_backup => "rotate" work?
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,19393,23636#msg-23636

I never got any replies about this. I just tried again with 3.2.1 Community, 
and it still doesn't work. Another example:

body common control {
     bundlesequence => { "editexample" };
     inputs => { "cfengine_stdlib.cf" };
}

bundle agent editexample
{
files:
  "/tmp/foo"
    create => "true",
    edit_line => insert_lines("It's right now: ${sys.date}"),
    edit_defaults => rotate;
}

body edit_defaults rotate
{
  empty_file_before_editing => "false";
#  edit_backup => "timestamp";
  edit_backup => "rotate";
  rotate => "4";
  max_file_size => "300000";
}


With edit_backup => "timestamp", it works fine:

$ cf-agent -KI -f ./src/tests/test_filebackup.cf
 -> Created file /tmp/foo, mode = 600
 -> Edited file /tmp/foo
$ cat /tmp/foo
It's right now: Wed Sep 28 23:07:33 2011
$ ls /tmp/foo*
/tmp/foo                                                    
/tmp/foo_1317269253_Wed_Sep_28_23_07_33_2011.cf-before-edit
$ cf-agent -KI -f ./src/tests/test_filebackup.cf
 -> Edited file /tmp/foo
$ ls /tmp/foo*
/tmp/foo                                                    
/tmp/foo_1317269253_Wed_Sep_28_23_07_33_2011.cf-before-edit 
/tmp/foo_1317269261_Wed_Sep_28_23_07_42_2011.cf-before-edit
$ cf-agent -KI -f ./src/tests/test_filebackup.cf
 -> Edited file /tmp/foo
$ ls /tmp/foo*
/tmp/foo                                                    
/tmp/foo_1317269261_Wed_Sep_28_23_07_42_2011.cf-before-edit
/tmp/foo_1317269253_Wed_Sep_28_23_07_33_2011.cf-before-edit 
/tmp/foo_1317269266_Wed_Sep_28_23_07_46_2011.cf-before-edit
$ cat /tmp/foo
It's right now: Wed Sep 28 23:07:33 2011
It's right now: Wed Sep 28 23:07:41 2011
It's right now: Wed Sep 28 23:07:46 2011


But with "rotate", it still just creates foo.cf-before-edit:

$ cf-agent -KI -f ./src/tests/test_filebackup.cf
 -> Created file /tmp/foo, mode = 600
 -> Edited file /tmp/foo
$ ls /tmp/foo*
/tmp/foo                /tmp/foo.cf-before-edit
$ cf-agent -KI -f ./src/tests/test_filebackup.cf
 -> Edited file /tmp/foo
$ ls /tmp/foo*
/tmp/foo                /tmp/foo.cf-before-edit
$ cat /tmp/foo
It's right now: Wed Sep 28 23:09:27 2011
It's right now: Wed Sep 28 23:09:32 2011
$ cat /tmp/foo.cf-before-edit 
It's right now: Wed Sep 28 23:09:27 2011


Just submitted a bug about this: https://cfengine.com/bugtracker/view.php?id=824

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to