开发者

rsync is overwriting read-only files. How do I prevent this?

I'm using rsync -avlz to sync files between my development server and my production server. On my production server I have some config files with options specific to that server (e.g. passwords, port numbers, etc.) and I don't want those files overwritten when I do the rsync.

However, even though those files have 444 permissions, they are still being overwritten. Can anyone explain to me why this is happening or point me in the direction of how to prevent it? It seems to me that setting the files to read-only would prevent rsync from updating them.

NOTE: I'd prefer to not have to specifically exclude files if I don't have to. I'd love to have the server know not to allow overwriting o开发者_运维百科f read-only files.


rsync does not care about "read-only", especially since you've told it to sync permissions as well. Keep local settings in a separate file and include them from the main configuration.


If your file system happens to be ext2/3/4, you could temporarily set the immutable on the file using chattr (Expect errors, though), eg.

chattr +i local.conf
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜