在SVN下保留配置文件的最佳方法?

时间:2021-10-25 20:08:57

What is the best way to keep your configuration files (e.g httpd.conf, my.cnf, .bashrc ...) under version control? In adition to the versioning benefit, I want the solution to work as backup as well, so that I can bring a brand new server and checkout (or export) the config files out of SVN directly

在版本控制下保存配置文件(例如httpd.conf,my.cnf,.bashrc ...)的最佳方法是什么?为了版本化的好处,我希望解决方案也可以作为备份,这样我就可以带来一个全新的服务器并直接从SVN签出(或导出)配置文件

A good touch will be to store the config file`s original path as well.

一个好的方法是存储配置文件的原始路径。

6 个解决方案

#1


4  

I revision-control my configuration files, but I use git instead of svn (which is easier when you have multiple machines). I have a bash script (called install.sh), also under the repository, which either copies or symlinks the files to their appropriate location on a machine.

我修改控制我的配置文件,但我使用git而不是svn(当你有多台机器时这更容易)。我有一个bash脚本(称为install.sh),也位于存储库下,可以将文件复制或符号链接到计算机上的适当位置。

So if I need to set up on a new machine, I just do a git clone of the repository (which is equivalent to an svn checkout) and run my install.sh to set up my config files in the appropriate locations. Having install.sh around means that I'm also storing the config files' original path, as you indicated you'd like.

因此,如果我需要在新机器上进行设置,我只需要执行存储库的git克隆(相当于svn checkout)并运行我的install.sh以在适当的位置设置我的配置文件。 install.sh周围意味着我也存储配置文件的原始路径,正如您所说的那样。

#2


2  

This is what I have implemented:

这是我实施的:

I have a server that does rsync of all the configs into one directory (say /data/configs/hostname/{etc,httpd}.

我有一台服务器将所有配置的rsync同步到一个目录中(比如/ data / configs / hostname / {etc,httpd}。

I have an rsync running every hour to transfer the changes. as soon as rsync is complete, there is an svnautocommit script that does autocommit of the changes. This way, I can roll back to any change or any version I want to.

我每小时运行一次rsync来传输更改。一旦rsync完成,就会有一个svnautocommit脚本自动提交更改。这样,我可以回滚到任何我想要的更改或任何版本。

You might need to plan the SVN directory structure based on your requirements.

您可能需要根据您的要求规划SVN目录结构。

#3


0  

I do this for several machines, ranging from old Solaris 8 boxes to Mac OS X, and I have a really simple layout:

我在几台机器上执行此操作,从旧的Solaris 8机箱到Mac OS X,我有一个非常简单的布局:

In my repository I have the following:

在我的存储库中,我有以下内容:

<root>/common
  /.emacs.d
  /.bash_common
  /scripts # platform-independent binary tools

<root>/linux
  .bashrc
  .emacs
  ...

<root>/solaris
  .bashrc
  .emacs
  ...

<root>/osx
  .bashrc
  .emacs
  ...

Each of the OS homedirs has an svn:externals reference to .emacs.d, .bash_common, and scripts, so those are not duplicated.

每个OS homedir都有一个svn:externals引用.emacs.d,.bash_common和脚本,因此不会重复。

In addition, I have a .bash_hostconfig in the linux and solaris directories with host-specific path configuration and such, because I have a very different setup at work than I do at home (FC5-8 and RHEL3-5, depending on where I am).

另外,我在linux和solaris目录中有一个.bash_hostconfig,具有特定于主机的路径配置等,因为我在工作时的设置与在家时的设置非常不同(FC5-8和RHEL3-5,取决于我在哪里上午)。

So, between these things, I have a pretty simple process for getting up and running on a new machine: I simply check out the /$platform into a temporary directory, and then overwrite everything in $HOME with those files. I don't need to store the original path, because it's always relative to $HOME this way.

因此,在这些事情之间,我有一个非常简单的启动和运行新机器的过程:我只需将/ $平台检入临时目录,然后用这些文件覆盖$ HOME中的所有内容。我不需要存储原始路径,因为它总是以这种方式相对于$ HOME。

#4


0  

We use CVS to store the configs in a directory structure that is as flat as possible. This technique is easily extended to SVN.

我们使用CVS将配置存储在尽可能平坦的目录结构中。这种技术很容易扩展到SVN。

Then we have a Makefile set up to use CVS export to:

然后我们将Makefile设置为使用CVS导出到:

  1. create a copy of the CVS directory structure without the CVS components,
  2. 在没有CVS组件的情况下创建CVS目录结构的副本,

  3. create the directory structure required for the target machine in your local directory as if you were in the root directory on the target machine, e.g. ./my_cvs_dir/etc/.. and ./my_cvs_dir/usr/local/newapp/..,
  4. 在本地目录中创建目标计算机所需的目录结构,就像您在目标计算机的根目录中一样,例如./my_cvs_dir/etc/ ..和./my_cvs_dir/usr/local/newapp / ..,

  5. copy the files from the CVS structure to the target directory structure,
  6. 将文件从CVS结构复制到目标目录结构,

  7. create a tarball for the target directory structure, and
  8. 为目标目录结构创建一个tarball,和

  9. deploy the tarball to the target machine.
  10. 将tarball部署到目标计算机。

We also have these tarballs set up in increasing specialisation, e.g. Sol10, Apache, specific app's, etc.

我们还设置了这些tarball,以增加专业化,例如: Sol10,Apache,特定应用程序等

HTH

cheers,

Rob

#5


0  

Well you could store all configuration files under a specific directory tree, one sub-directory per application. Since most applications should have a directive to specify the config path, this is then the only thing to be changed (or if you have hard coded config files, maybe something like include is supported) per server.

那么你可以将所有配置文件存储在特定的目录树下,每个应用程序一个子目录。由于大多数应用程序都应该有一个指令来指定配置路径,因此每个服务器只能更改(或者如果您有硬编码的配置文件,可能支持包含类似的东西)。

And this tree could then be checked into whatever VCS you like.

然后可以将此树检入您喜欢的任何VCS。

For deploying you can write a shell script or such a thing which initializes everything to use your config file tree.

对于部署,您可以编写一个shell脚本或类似的东西来初始化所有内容以使用您的配置文件树。

#6


0  

As you want a central store anyway, you may go for something slightly more complicated like Slack. You administer and version control the files at a push server, then rsync it to the clients. The explanation of subroles has some examples on how to structure the tree.

无论如何你想要一个*商店,你可能会选择像Slack这样复杂得多的东西。您可以在推送服务器上管理和版本控制文件,然后将其同步到客户端。子角色的解释有一些关于如何构造树的例子。

#1


4  

I revision-control my configuration files, but I use git instead of svn (which is easier when you have multiple machines). I have a bash script (called install.sh), also under the repository, which either copies or symlinks the files to their appropriate location on a machine.

我修改控制我的配置文件,但我使用git而不是svn(当你有多台机器时这更容易)。我有一个bash脚本(称为install.sh),也位于存储库下,可以将文件复制或符号链接到计算机上的适当位置。

So if I need to set up on a new machine, I just do a git clone of the repository (which is equivalent to an svn checkout) and run my install.sh to set up my config files in the appropriate locations. Having install.sh around means that I'm also storing the config files' original path, as you indicated you'd like.

因此,如果我需要在新机器上进行设置,我只需要执行存储库的git克隆(相当于svn checkout)并运行我的install.sh以在适当的位置设置我的配置文件。 install.sh周围意味着我也存储配置文件的原始路径,正如您所说的那样。

#2


2  

This is what I have implemented:

这是我实施的:

I have a server that does rsync of all the configs into one directory (say /data/configs/hostname/{etc,httpd}.

我有一台服务器将所有配置的rsync同步到一个目录中(比如/ data / configs / hostname / {etc,httpd}。

I have an rsync running every hour to transfer the changes. as soon as rsync is complete, there is an svnautocommit script that does autocommit of the changes. This way, I can roll back to any change or any version I want to.

我每小时运行一次rsync来传输更改。一旦rsync完成,就会有一个svnautocommit脚本自动提交更改。这样,我可以回滚到任何我想要的更改或任何版本。

You might need to plan the SVN directory structure based on your requirements.

您可能需要根据您的要求规划SVN目录结构。

#3


0  

I do this for several machines, ranging from old Solaris 8 boxes to Mac OS X, and I have a really simple layout:

我在几台机器上执行此操作,从旧的Solaris 8机箱到Mac OS X,我有一个非常简单的布局:

In my repository I have the following:

在我的存储库中,我有以下内容:

<root>/common
  /.emacs.d
  /.bash_common
  /scripts # platform-independent binary tools

<root>/linux
  .bashrc
  .emacs
  ...

<root>/solaris
  .bashrc
  .emacs
  ...

<root>/osx
  .bashrc
  .emacs
  ...

Each of the OS homedirs has an svn:externals reference to .emacs.d, .bash_common, and scripts, so those are not duplicated.

每个OS homedir都有一个svn:externals引用.emacs.d,.bash_common和脚本,因此不会重复。

In addition, I have a .bash_hostconfig in the linux and solaris directories with host-specific path configuration and such, because I have a very different setup at work than I do at home (FC5-8 and RHEL3-5, depending on where I am).

另外,我在linux和solaris目录中有一个.bash_hostconfig,具有特定于主机的路径配置等,因为我在工作时的设置与在家时的设置非常不同(FC5-8和RHEL3-5,取决于我在哪里上午)。

So, between these things, I have a pretty simple process for getting up and running on a new machine: I simply check out the /$platform into a temporary directory, and then overwrite everything in $HOME with those files. I don't need to store the original path, because it's always relative to $HOME this way.

因此,在这些事情之间,我有一个非常简单的启动和运行新机器的过程:我只需将/ $平台检入临时目录,然后用这些文件覆盖$ HOME中的所有内容。我不需要存储原始路径,因为它总是以这种方式相对于$ HOME。

#4


0  

We use CVS to store the configs in a directory structure that is as flat as possible. This technique is easily extended to SVN.

我们使用CVS将配置存储在尽可能平坦的目录结构中。这种技术很容易扩展到SVN。

Then we have a Makefile set up to use CVS export to:

然后我们将Makefile设置为使用CVS导出到:

  1. create a copy of the CVS directory structure without the CVS components,
  2. 在没有CVS组件的情况下创建CVS目录结构的副本,

  3. create the directory structure required for the target machine in your local directory as if you were in the root directory on the target machine, e.g. ./my_cvs_dir/etc/.. and ./my_cvs_dir/usr/local/newapp/..,
  4. 在本地目录中创建目标计算机所需的目录结构,就像您在目标计算机的根目录中一样,例如./my_cvs_dir/etc/ ..和./my_cvs_dir/usr/local/newapp / ..,

  5. copy the files from the CVS structure to the target directory structure,
  6. 将文件从CVS结构复制到目标目录结构,

  7. create a tarball for the target directory structure, and
  8. 为目标目录结构创建一个tarball,和

  9. deploy the tarball to the target machine.
  10. 将tarball部署到目标计算机。

We also have these tarballs set up in increasing specialisation, e.g. Sol10, Apache, specific app's, etc.

我们还设置了这些tarball,以增加专业化,例如: Sol10,Apache,特定应用程序等

HTH

cheers,

Rob

#5


0  

Well you could store all configuration files under a specific directory tree, one sub-directory per application. Since most applications should have a directive to specify the config path, this is then the only thing to be changed (or if you have hard coded config files, maybe something like include is supported) per server.

那么你可以将所有配置文件存储在特定的目录树下,每个应用程序一个子目录。由于大多数应用程序都应该有一个指令来指定配置路径,因此每个服务器只能更改(或者如果您有硬编码的配置文件,可能支持包含类似的东西)。

And this tree could then be checked into whatever VCS you like.

然后可以将此树检入您喜欢的任何VCS。

For deploying you can write a shell script or such a thing which initializes everything to use your config file tree.

对于部署,您可以编写一个shell脚本或类似的东西来初始化所有内容以使用您的配置文件树。

#6


0  

As you want a central store anyway, you may go for something slightly more complicated like Slack. You administer and version control the files at a push server, then rsync it to the clients. The explanation of subroles has some examples on how to structure the tree.

无论如何你想要一个*商店,你可能会选择像Slack这样复杂得多的东西。您可以在推送服务器上管理和版本控制文件,然后将其同步到客户端。子角色的解释有一些关于如何构造树的例子。