[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: keeping mtimes in sync
From: |
Brendan Strejcek |
Subject: |
Re: keeping mtimes in sync |
Date: |
Thu, 11 Mar 2004 11:09:04 -0600 |
User-agent: |
Mutt/1.3.28i |
rader@ginseng.hep.wisc.edu wrote:
> Er, your example shows maintence of *source* mtimes--not destination
> mtimes? Is there a way to keep destination mtimes in sync?
>
> $ cat cftest
> #!/usr/sbin/cfagent -qIKf
> control: actionsequence = ( copy )
> copy: /tmp/a dest=/tmp/b type=mtime
> $ cp /etc/motd /tmp/a
> $ touch -d 01/01/70 /tmp/a
> $ ./cftest
> cfengine:: Copying from localhost:/tmp/a
> cfengine:: Object /tmp/b had permission 600, changed it to 644
> $ touch /tmp/b
> $ ./cftest # HERE would like cfengine to change /tmp/b's to mtime 01/01/70
> $ ls -l /tmp/a /tmp/b
> -rw-r--r-- 1 rader rader 83 Jan 1 1970 /tmp/a
> -rw-r--r-- 1 rader rader 83 Mar 11 04:27 /tmp/b
When using type=ctime or type=mtime, cfagent only copies the source to
the destination if the source is *newer* that the dest (by whichever
time criteria specified). The problem here is not that cfagent is not
maintaining the times, but that it thinks no copy is necessary because
the dest is newer than the source. Neither type=sum or type=byte will
work because file content change is needed to trigger a copy. I don't
think cfengine can do what you want. Someone correct me if I am wrong.
What problem are you trying to solve?
If you really need a group of files to be in sync, use rsync. That has
the behavior you seem to seek:
$ mkdir a
$ mkdir b
$ cp /etc/passwd a
$ rsync -ar a/ b
$ find a b
a
a/passwd
b
b/passwd
$ touch -d 01/01/70 a/passwd
$ ls -alR a b
a:
total 4
drwxr-xr-x 2 brendan staff 512 Mar 11 10:47 .
drwxr-xr-x 20 brendan staff 1536 Mar 11 10:48 ..
-rw-r--r-- 1 brendan staff 969 Jan 1 1970 passwd
b:
total 4
drwxr-xr-x 2 brendan staff 512 Mar 11 10:47 .
drwxr-xr-x 20 brendan staff 1536 Mar 11 10:48 ..
-rw-r--r-- 1 brendan staff 969 Mar 11 10:47 passwd
$ rsync -ar a/ b
$ ls -alR a b
a:
total 4
drwxr-xr-x 2 brendan staff 512 Mar 11 10:47 .
drwxr-xr-x 20 brendan staff 1536 Mar 11 10:48 ..
-rw-r--r-- 1 brendan staff 969 Jan 1 1970 passwd
b:
total 4
drwxr-xr-x 2 brendan staff 512 Mar 11 10:47 .
drwxr-xr-x 20 brendan staff 1536 Mar 11 10:48 ..
-rw-r--r-- 1 brendan staff 969 Jan 1 1970 passwd
$
I thought there might be some way to achieve your goal by trying to copy
the containing directory with cfagent (since that is what stores the
metadata you want to preserve) but I could not make it work.
-- Brendan