14
7
I want to manage the updates of my Linux system in a similar fashion as Git does it, by being able to move back and forth within "revisions". How could I do that?
14
7
I want to manage the updates of my Linux system in a similar fashion as Git does it, by being able to move back and forth within "revisions". How could I do that?
12
What you probably are looking for are called configuration management tools. There are several to choose from but and it's very subjective which one is best in any situation.
I personally found Puppet to be quite easy to get started with, but other popular choices are Salt and Ansible.
I already used puppet in vagrant, but I don't remember ever being able to undo some messy thing I did in my OS... – Patrick Villela – 2015-01-13T21:44:51.060
4Configuration management tools generally do not provide "rollback" functionality. The "rollback" is blowing away the system and using the configuration management tool to reconfigure the system. For example, you might use a bare metal provisioning tool like Razor to format and reinstall the OS. Then, it hands off to a tool like Chef to apply the configuration. – ctc – 2015-01-14T01:38:42.577
2Is the witch intended? :) – Ruslan – 2015-01-14T05:14:02.790
Is cfengine dead? I remember trying to get something I was happy with to use on my small cluster back when I was the sysadmin. But I never ended up deploying it. – Peter Cordes – 2015-01-14T11:17:23.580
With any of these tools, you get version control by keeping your master config files in git. What you get from them is centralizing and reducing configuration of a whole system to one of a few text files. – Peter Cordes – 2015-01-15T08:45:26.563
(meta) I earlier suggested that part about git as an edit because I thought it made Nifle's answer a better answer to the original question, in case it wasn't obvious to people unfamiliar with such tools how this was an answer. – Peter Cordes – 2015-01-15T08:46:52.200
12
You probably should look at NixOS, which uses the Nix package manager.
NixOS is a GNU/Linux distribution that aims to improve the state of the art in system configuration management. In existing distributions, actions such as upgrades are dangerous: upgrading a package can cause other packages to break, upgrading an entire system is much less reliable than reinstalling from scratch, you can’t safely test what the results of a configuration change will be, you cannot easily undo changes to the system, and so on.
10
This is likely overkill for your question, but the easiest way to be able to revert system-level / massive changes is snapshotting:
https://en.wikipedia.org/wiki/Snapshot_%28computer_storage%29
You have not mentioned the specifics of your rig, but seeing as you are familiar with git, it wouldn't be too much of a stretch to imagine you might be interested in using a more complex file system. If you were to use a next-gen file system (ignore the click-bait-y name) you would be able to completely "rewind" your entire system with a mere command punched into your terminal. Any and all changes made would be reverted with very little delay / effort. ZFS would be your best bet and you could refer to this amazing Ars article to see if it might be something worth it for you (there are many many many other great features too):
2Another option is btrfs, which BTW has official enterprise support from Ubuntu, SUSE >= 11, Oracle. Although it is still being developed and blahblahblah, it is reliable for everyday desktop usage and performs damn well. – ignis – 2015-01-14T11:11:21.767
1
@ignis: I've recently encountered an inconsistent and non-recoverable Btrfs despite a RAID 5 underneath, and heard about two more instances at work. So I wouldn't lightly disregard those warnings about it not being ready for production use. I didn't want to beleive it myself before I encountered it. Might have been due to bad RAM, perhaps, which is one of the reasons why ZFS people strongly advise the use of ECC memory. I guess the same might apply to Btrfs.
– MvG – 2015-01-14T17:36:17.6976
Depending on what you mean by "updates", you may be interested in configuration management tools like etckeeper, which permit you to record changes to the system configuration automatically, and to revert to earlier configurations.
If Git is a familiar tool, and if by "updates" you mean "updates to system configuration" as opposed to "updates to system packages" or "updates to all files stored on the server" then this may be what you're looking for.
It's worth considering that whether you're using tools like Puppet, Ansible, Etckeeper etc, it's not always possible to "roll back" cleanly without loss of data, unless you go the whole hog (eg snapshotting, as mentioned in another answer). The right approach will depend on your situation (eg snapshotting would not be appropriate for a production system where you might lose customer orders when rolling back).
2
I have used OpenVMS in the past, it comes by default with a versioning file system.
If tools like puppet do not go far enough maybe a versioning file systems is what you are looking for.
1
If you really want to manage your whole system (including kernel version) like git, you're looking for NixOS.
For a less-involved version you can use NixOS's package manager, nix, from almost any unix. Nix can be installed as a simple user, though it is easier to install it as root. Once nix is installed, you can use it to install packages as a non-privileged user, and it runs fine alongside your existing package manager, with no conflicts. It is also very easy to completely remove nix from your system, so there's really no excuse not to try it out. ;-)
To directly address your question, Nix defines your complete installed system as an environment, which is, much like a git commit, a pointer to a set of pointers to very specific versions of all of the installed packages.
When Nix upgrades a package, it creates a new environment, which points to a new set of pointers to packages (mostly to existing ones, for packages which have not been updated; again, this is very similar to a new git commit, which mostly points to previous unchanged files and a few new versions of modified files).
It is, of course, trivial to switch to a previous version of the environment and, I believe, fork (i.e. create a new environment based on an older-than-last one). An environment can be loaded for a specific shell (it is, in fact, the set of environment variables available to a shell, hence the name), so you can also quite easily have different environments for different projects on the same machine. No more dependency problems because an unrelated project needs another version of a library!
NixOS takes that to the next level and manages your whole computer, including the kernel, in a similar fashion, allowing for very low risk upgrades of the whole machine.
I haven't finished reading all of them, but I recommend lethalman's Nix pills as an introduction to Nix.
0
If you're the experimental type, you might try just checking in your entire file system into a local git repository. This would be... interesting, I think.
git init
in the root directory /
git add -A .
git commit -m "Initial Snapshot"
git commit -Am "Snapshot X"
or similarSome benefits would be:
gitk
and git diff
Some oddities might include:
git
hopefully working as expected when you're in a source code directory nested in the root git
container.3This approach would most likely fail horribly, since git wont be handling permissions properly. Assuming you do all that as root, you'd essentially chown entire file system to root, and that, in turn, will disrupt write operations. For instance, you take a snapshot, restore it, apache log directory owner becomes root (instead of http), apache cant write to directory, fails to start. I know that, because I tried a similar thing, but on a much smaller scale, and even on that, there were problems. – Tuncay Göncüoğlu – 2015-01-14T11:43:56.267
Take a look at Nix, as suggested in another answer ;) – Michael Pankov – 2015-01-14T11:48:10.560
Good to know! I thought it did handle permissions, at least the octet, as my scripts retain the x flag on clone, but I didn't think about file and group ownership – Ehryk – 2015-01-14T14:52:16.210
It does appear that there are additional tools that will retain full permissions and ownerships, if you did require doing so. One such tool is git-cache-meta, and Here's a list
– Ehryk – 2015-01-14T15:41:31.037
As a Linux/Unix systems administrator who deals with the deeper aspects of how Linux/Unix systems work, I cannot imagine what kind of changes one would need to make to their system to require a Git-like revision system. The main thing that gets changes on these systems are software installs and config files. Config files are easy to manually backup and keep track of. And it falls into a “set it and forget it” mindset. – JakeGould – 2015-01-30T20:54:08.427