sync directory like rsync --delete

379 views
Skip to first unread message

ruisse...@gmail.com

unread,
May 3, 2013, 10:57:04 AM5/3/13
to help-c...@googlegroups.com

Hi I want to sync ( like rsync --delete) the following directory:
    "/etc/autofs.d"
      copy_from => u_cp("$(sys.workdir)/sourcefiles/etc/autofs.d"),
      # depth_search => recurse("1"),
      depth_search => recurse_ignore("inf",".svn"),
      # file_select => all,
      file_select => by_name(".*"),
      delete => tidy,
      perms => mog("644","root","root"),
      classes => if_repaired("restart_autofs");

I got the following:
!! Promise constraint conflicts - /etc/autofs.d cannot be deleted and exist at the same time

Files that dont'exist in $(sys.workdir)/sourcefiles/etc/autofs.d should be deleted in /etc/autofs.d .
All other files should be copied.
Any help is welcome!

Jean Rémond

unread,
May 3, 2013, 11:01:27 AM5/3/13
to ruisse...@gmail.com, help-c...@googlegroups.com
Hi

Have a look at cfengine_stdlib.cf
What you are looking for is "purge => true", you don't need "delete => tidy"
https://cfengine.com/manuals/cf3-Reference#copy_005ffrom-in-files

body copy_from sync_cp(from,server)
{
servers     => { "$(server)" };
source      => "$(from)";
purge       => "true";
preserve    => "true";
type_check  => "false";
}





--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to help-cfengin...@googlegroups.com.
To post to this group, send email to help-c...@googlegroups.com.
Visit this group at http://groups.google.com/group/help-cfengine?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Neil Watson

unread,
May 3, 2013, 11:06:55 AM5/3/13
to help-c...@googlegroups.com
See the purge attribute of the copy_from body.
http://cfengine.com/manuals/cf3-Reference#copy_005ffrom-in-files

--
Neil Watson
Linux/UNIX Consultant
http://watson-wilson.ca

ruisse...@gmail.com

unread,
May 3, 2013, 11:22:25 AM5/3/13
to help-c...@googlegroups.com, cfen...@watson-wilson.ca
I already tried purge:
    "/etc/autofs.d"
      copy_from
=> u_cp("$(sys.workdir)/sourcefiles/etc/autofs.d"),

      depth_search
=> recurse_ignore("inf",".svn"),

      file_select
=> by_name(".*"),

      purge
=> "true",

      perms
=> mog("644","root","root"),
      classes
=> if_repaired("restart_autofs");

Constraint lvalue 'purge' is not allowed in bundle category 'files', near token 'true"'

Neil Watson

unread,
May 3, 2013, 11:26:15 AM5/3/13
to help-c...@googlegroups.com
On Fri, May 03, 2013 at 08:22:25AM -0700, ruisse...@gmail.com wrote:
>
>
> I already tried purge:

Purge a body attribute not a promise attribute. It goes in the copy_from
body, not the promise body.

ruisse...@gmail.com

unread,
May 3, 2013, 11:39:48 AM5/3/13
to help-c...@googlegroups.com, cfen...@watson-wilson.ca
Thanks, it works. I made a separate body copy_from statement which include purge.

mike.w...@verticalsysadmin.com

unread,
Jul 26, 2017, 11:50:08 PM7/26/17
to help-cfengine
Is the behavior actually similar to the rsync option, though?  Which specific option is it similar to: --delete-before, --delete-during, or --delete-after?

--Mike Weilgart
Reply all
Reply to author
Forward
0 new messages