Skip to main content

Creating a Git repository for configs and more

Don't be the person with a ton of .bak configuration files on your server.

Just like in software engineering projects, systems and DevOps engineering greatly benefit from source control. Not just for configuration file backups, but for revision history, collaboration, portability, and more.

Configuration management is a big topic of its own, very close to IaC, CaC, and other fancy words. It becomes extremely important when dealing with tens, hundreds, sometimes thousands of servers, and carries a ton of additional complexity.

That complexity is often not worth it when you're working with a handful of servers or fewer. In the cattle vs pets analogy, we'll be sticking to the pets in this course. However, that doesn't mean we can't benefit from some configuration management.

Repository layout

Let's create a new Git repository. This will house all important configuration files, scripts and tools for operations, as well as some docs we can revisit when doing future maintenance.

config/
├─ bin/
├─ nginx/
├─ php/
├─ mysql/
├─ misc/
└─ README.md

This is a good starter layout, which anticipates some helper scripts and programs in the bin directory, the Nginx configuration files, and maybe error templates in the nginx directory. The php and mysql directories will hold our PHP and MySQL/MariaDB configs (you can call this mariadb instead if you like), and misc for all other configs.

The README.md file can be used for notes on where things are and how things work, as well as common commands, known problems, TODOs, and other things.

Go ahead and create this layout on your local system. Hopefully you're using one with Git pre-installed:

mkdir config && cd config
mkdir bin nginx php mysql misc

touch bin/.gitkeep
touch nginx/.gitkeep
touch php/.gitkeep
touch mysql/.gitkeep
touch misc/.gitkeep

echo "# Important Things" > README.md

As your project grows, you'll expand on this layout and move things around when needed. Since all directories are currently empty, we can place an empty placeholder .gitkeep file in each to make sure the structure is committed to your Git repository.

git init
git add .
git commit -m "The self-hosting journey begins"

You can host it on GitHub for easy access, but make sure this is a private repository as it will contain plenty of potentially sensitive files.

Enroll
Enjoying the course content? Enroll today to keep track of your progress, access premium lessons and more.