[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

Let's manage git under /etc with etckeeper

My name is Ito and I am an infrastructure engineer.
When operating a Linux server, rewriting configuration files is done on a daily basis.

When changing settings, you often back up the file by adding a date name to the end of the file.

Like this.

# ls -al |grep httpd.conf -rw-r--r-- 1 root root 16730 Jan 25 22:59 httpd.conf -rw-r--r-- 1 root root 16730 Jan 25 22:59 httpd. conf_20151225 -rw-r--r-- 1 root root 16730 Jan 25 22:59 httpd.conf_20160120

However, if you create a backup file every time you change settings, the files will be scattered.
The more files there are, the more likely mistakes will occur. This is not really good for your mental health.

In such cases, we recommend using a VCS (version control system) called etckeeper to manage it!

Of course, etckeeper will commit manually, but it will also commit automatically at the following times.
・When executing the yum command
・When the date changes

Install it for now

I will try installing etckeeper.
As I briefly touched on earlier, VCS is required. This time we will install git.

#yum install git

Install etckeeper from the epel repository.

#yum install --enablerepo=epel etckeeper

It was installed successfully.

# rpm -qa |grep etckeeper etckeeper-0.64-1.el5.rf

Try using it

First, create a repository.

# etckeeper init Initialized empty Git repository in /etc/.git/

I'll try committing.

# etckeeper commit "First commit" [master (root-commit) 970f0b3] First commit Author: vagrant<vagrant@cli> 1174 files changed, 122593 insertions(+), 0 deletions(-) create mode 100755 .etckeeper create mode 100644 yum/version-groups.conf

Check the commit log.
Git commands can be used in etckeeper vcs.

# etckeeper vcs log commit 970f0b335acdf586e099d57f1bc95d442bff853f Author: vagrant<vagrant@cli> Date: Fri Jan 29 21:02:33 2016 +0900 First commit

Let's try installing Apache.
etckeeper will commit on the way.

#yum install httpd (omitted) etckeeper: pre transaction commit Updating : httpd-tools-2.2.15-47.el6.centos.1.x86_64 1/4 Updating : httpd-2.2.15-47.el6.centos.1. x86_64 2/4 Cleanup : httpd-2.2.15-47.el6.centos.x86_64 3/4 Cleanup : httpd-tools-2.2.15-47.el6.centos.x86_64 4/4 etckeeper: post transaction commit Verifying : httpd -tools-2.2.15-47.el6.centos.1.x86_64 1/4 Verifying : httpd-2.2.15-47.el6.centos.1.x86_64 2/4 Verifying : httpd-tools-2.2.15-47 .el6.centos.x86_64 3/4 Verifying : httpd-2.2.15-47.el6.centos.x86_64 4/4 (omitted)

Let's try editing httpd.conf and checking the log when committing.

# etckeeper vcs log commit a6cee87ff14bcf90587e98017d8a737777bcc5c0 Author: vagrant<vagrant@cli> Date: Fri Jan 29 22:43:53 2016 +0900 edit httpd.conf commit 970f0b335acdf586e099d57f1bc95d442bff853f Author: vagrant<vagrant@cli> Date: Fri Jan 29 21:02:33 2016 +0900 First commit

Let's check the diff to see which part was edited.

# etckeeper vcs diff 970f0b335acdf586e099d57f1bc95d442bff853f 66aefb8e71a7526988c0b3d3863fd6e7e3ec0b54 diff --git a/httpd/conf/httpd.conf b/httpd/conf/httpd.conf index 579d194..58 70596 100644 --- a/httpd/conf/httpd.conf +++ b /httpd/conf/httpd.conf @@ -1,3 +1,4 @@ +#test # # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions.

Let's go back to a certain point.

# etckeeper vcs revert a6cee87ff14bcf90587e98017d8a737777bcc5c0 Finished one revert. # On branch master nothing to commit (working directory clean)

This is roughly how you would use it.
It's nice to be able to avoid having a large number of configuration files under /etc/!

That's how to use etckeeper.
Use etckeeper to manage /etc files beautifully!

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
2,897
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author