# How do you back up and restore /etc?

**URL:** <https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455>\
**Category:** General\
**Created:** [March 18, 2025, 12:49pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455 "2025-03-18T12:49:09Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/johnatl/32/3485_2.png) [@JohnAtl](https://universal-blue.discourse.group/u/JohnAtl)\
**Post date:** [March 18, 2025, 12:49pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/1 "2025-03-18T12:49:09Z")

</div>

`/etc` is a weird amalgamation of system- and human-created and edited files.  
When reinstalling a system, for instance, one should not copy all files from a backup into `/etc`, as drive UUIDs, etc. might have changed.

It also isn’t possible to, say, back up files that have changed since the system install datetime (via /etc/machine-id, perhaps), as most files in `/etc` are touched by system updates.

I use [chezmoi](https://www.chezmoi.io/) to back up my `~/.config`, etc. to a github repo, but it doesn’t work with folders outside `$HOME`.

One approach is to copy `/etc` into a folder in my `$HOME`, then pick and choose what to back up from there. But this seems clunky, and perhaps failure-prone.

Also, are there other folders similar to `/etc` that require the same attention?

Suggestions?

(I do keep regular bare metal backups of `/mnt/btrfs-root/root`, `/mnt/btrfs-root/var`, and `/mnt/btrfs-root/home`, along with Vorta backups of everything else.)

---

<div class="post-metadata">

**Author:** ![tingo](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/tingo/32/3404_2.png) [@tingo](https://universal-blue.discourse.group/u/tingo)\
**Post date:** [April 1, 2025, 7:48pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/2 "2025-04-01T19:48:48Z")

</div>

If Bluefin supports [etckeeper](https://etckeeper.branchable.com/), that is one way to do it. Alasi, I couldn’t figure out if etckeeper is supported.

---

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/johnatl/32/3485_2.png) [@JohnAtl](https://universal-blue.discourse.group/u/JohnAtl)\
**Post date:** [April 1, 2025, 7:57pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/3 "2025-04-01T19:57:28Z")

</div>

Thanks!  
It isn’t built in, nor is it in brew. I’ve downloaded the source and will give it a look.

---

<div class="post-metadata">

**Author:** ![zilexa](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/zilexa/32/2221_2.png) [@zilexa](https://universal-blue.discourse.group/u/zilexa)\
**Post date:** [April 15, 2025, 9:53pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/4 "2025-04-15T21:53:32Z")

</div>

Can’t you just use the native snapshot feature of the btrfs filesystem?

For example my Documents, Pictures folders are in a btrfs subvolume that I created `/mnt/userdata` . Then symlinked back to $HOME.  
I moved my Desktop folder into Documents.

This way for my personal files I can simply backup `userdata`or use whatever sync tool to sync to a cloud or private cloud.  
Or even use a tool like [btrbk](https://digint.ch/btrbk/) to daily snapshot and sync this subvolume to a different drive or even to another pc/laptop (btrbk supports ssh).

You could probably create a subvolume `/etc1` do a `mv /etc/ /etc1/`, then delete the first folder and rename the other to `/etc`.  
Now you can easily snapshot, compress sync or do whatever you want with it via btrfs.

I believe (could be wrong) OpenSuse Tumbleweed or Manjaro actually uses separate btrfs subvolumes for these typical Linux folders.

I’m surprised Fedora Silverblue doesn’t leverage the btrfs snapshotting features more.

---

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/johnatl/32/3485_2.png) [@JohnAtl](https://universal-blue.discourse.group/u/JohnAtl)\
**Post date:** [April 16, 2025, 1:08am UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/5 "2025-04-16T01:08:21Z")

</div>

> [@JohnAtl](#):
>
> When reinstalling a system, for instance, one should not copy all files from a backup into `/etc`, as drive UUIDs, etc. might have changed.

Thanks. Yeah, I think the above, from my original post, is where a lot of the difficulty comes in.  
I have a script that snapshots root, home, and var, then uses rsync to do an incremental backup to an external drive.  
I also use vorta to backup up my home and data to my iMac that backs up too Backblaze.  
So I’m covered on backups.  
But, etc is different due to the mix of system and user configs.

---

<div class="post-metadata">

**Author:** ![mxj4](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/mxj4/32/5839_2.png) [@mxj4](https://universal-blue.discourse.group/u/mxj4)\
**Post date:** [April 16, 2025, 4:46pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/6 "2025-04-16T16:46:09Z")

</div>

Default `/etc` shipped by the image is under `/usr/etc`, hence I’m using a combination of

```auto
ostree admin config-diff

```

and

```auto
diff -yrW200 --suppress-common-lines /usr/etc /etc

```

to get the list of changed files under `/etc`.

---

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/johnatl/32/3485_2.png) [@JohnAtl](https://universal-blue.discourse.group/u/JohnAtl)\
**Post date:** [April 16, 2025, 10:40pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/7 "2025-04-16T22:40:58Z")

</div>

Thanks.  
I’ll look into those.

---

<div class="post-metadata">

**Author:** ![klmcw](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@klmcw](https://universal-blue.discourse.group/u/klmcw)\
**Post date:** [April 17, 2025, 2:52am UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/8 "2025-04-17T02:52:10Z")

</div>

Thanks to @mxj4 for getting to the important commands.

I wrote an article about this here …

> [@Did You Know? How ostree update merges changes into etc and var](https://universal-blue.discourse.group/t/did-you-know-how-ostree-update-merges-changes-into-etc-and-var/7233):
>
> Did You Know? How ostree (rpm-ostree) update merges changes into etc and var Or Why systems based on ostree are NOT immutable As I continued my deep dive into [bluefin](https://projectbluefin.io/), I realized that changes being made to the bluefin bootc image did not appear to handle deletion of files other than to not include them in the image. This made me wonder, what happens to the files in the read-write filesystems of an existing install? ostree Filesystems The /etc and /var directories are the only writeable dirs (a…

---

<div class="post-metadata">

**Author:** ![JohnAtl](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/johnatl/32/3485_2.png) [@JohnAtl](https://universal-blue.discourse.group/u/JohnAtl)\
**Post date:** [April 17, 2025, 7:50am UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/9 "2025-04-17T07:50:10Z")

</div>

Thanks.  
I look forward to reading it.

---

<div class="post-metadata">

**Author:** ![tom71](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@tom71](https://universal-blue.discourse.group/u/tom71)\
**Post date:** [March 1, 2026, 9:15am UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/10 "2026-03-01T09:15:43Z")

</div>

Sorry for coming late to the discussion.

Regarding “etckeeper”, is it possible to layer it without the dnf dependency, e.g. “rpm-ostree install etckeeper --excludepkgs=dnf”? It might solve the problem of dnf messing with the rpm-ostree upgrades. Just a thought, I don’t know if it works.

Or just to use plain git sync with git-crypt (homebrew-installed or layered in) to protect sensitive information?

Another option is to make a systemd service and timer that will make regular backups of /etc directory and place the tar.gz files in user’s home directory, with optional pruning (removing the old ones after a while). That way, the etc folder tgz “snapshot” can be saved using Pika backup or some other home folder backup app.

BTW, thanks to all the developers for the finest set of linux distributions that I encountered since 1994.

Tom

---

<div class="post-metadata">

**Author:** ![Danathar](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/danathar/32/7758_2.png) [@Danathar](https://universal-blue.discourse.group/u/Danathar)\
**Post date:** [March 2, 2026, 3:20pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/11 "2026-03-02T15:20:24Z")

</div>

> [@tom71](#):
>
> Sorry for coming late to the discussion.
> 
> Regarding “etckeeper”, is it possible to layer it without the dnf dependency, e.g. “rpm-ostree install etckeeper --excludepkgs=dnf”? It might solve the problem of dnf messing with the rpm-ostree upgrades. Just a thought, I don’t know if it works.
> 
> Or just to use plain git sync with git-crypt (homebrew-installed or layered in) to protect sensitive information?
> 
> Another option is to make a systemd service and timer that will make regular backups of /etc directory and place the tar.gz files in user’s home directory, with optional pruning (removing the old ones after a while). That way, the etc folder tgz “snapshot” can be saved using Pika backup or some other home folder backup app.
> 
> BTW, thanks to all the developers for the finest set of Linux distributions that I encountered since 1994.
> 
> Tom

I had looked into this as well, wanting to use git for tracking changes in /etc. Unfortunately, from what I’ve read, etckeeper is just not going to work as it uses hooks into dnf.

I like your idea of basically engineering something with systemd and git. Maybe that would work.

---

<div class="post-metadata">

**Author:** ![klmcw](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@klmcw](https://universal-blue.discourse.group/u/klmcw)\
**Post date:** [March 3, 2026, 4:45pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/12 "2026-03-03T16:45:07Z")

</div>

The concepts around the ideas presented here are definitely worth considering.

Here is where I landed.

1. I realized that creating a git repo out of the entire `/etc` dir was too heavy handed. Very few files are customized over time.
2. It would be better to track changed files in `/etc` by copying them (don’t forget the details: perms, SELinux attrs, special file types, etc.) to a dir in $HOME that is practical to be a git repo.

This allows them to be included in the backup of $HOME to NAS, compared to `/usr/etc`, use `git diff` to analyze changes over time, etc. And minimize manual post-install steps.

I am definitely not proposing my solution (don’t do what I do). Rather, I am simply offering some food for thought …

---

<div class="post-metadata">

**Author:** ![locke496](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/locke496/32/8035_2.png) [@locke496](https://universal-blue.discourse.group/u/locke496)\
**Post date:** [March 3, 2026, 5:59pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/13 "2026-03-03T17:59:05Z")

</div>

Sounds interesting. Yes: perms, user/group owners, perhaps file types must be recorded and backed up. Is it really required for the SELinux attrs? Because, if I copy something back to `/etc/` wouldn’t it be labeled according to the policy for `/etc`?

---

<div class="post-metadata">

**Author:** ![locke496](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/locke496/32/8035_2.png) [@locke496](https://universal-blue.discourse.group/u/locke496)\
**Post date:** [March 3, 2026, 6:17pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/14 "2026-03-03T18:17:26Z")

</div>

There is one disadvantage having the `.git` repository files in `/etc/`

Namely: `sudo ostree admin config-diff` as this would show all git repository files as newly added.

Perhaps `sudo ostree admin config-diff | grep -v ‘A .git` would help 😁

---

<div class="post-metadata">

**Author:** ![Danathar](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/danathar/32/7758_2.png) [@Danathar](https://universal-blue.discourse.group/u/Danathar)\
**Post date:** [March 3, 2026, 10:02pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/15 "2026-03-03T22:02:12Z")

</div>

Oh yea, that’s quite interesting. Thanks!

---

<div class="post-metadata">

**Author:** ![klmcw](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@klmcw](https://universal-blue.discourse.group/u/klmcw)\
**Post date:** [March 4, 2026, 1:30pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/16 "2026-03-04T13:30:28Z")

</div>

> [@locke496](#):
>
> Is it really required for the SELinux attrs?

Not for the happy path - if all goes well - no.

> **[SELinux - RPM packages, ostree commits](https://coreos.github.io/rpm-ostree/architecture-core/#selinux)**
>
> On the compose side, to generate the “base image” the core idea is that we take a set of packages as input, along with other configuration and data and generate a single OSTree commit - a versioned filesystem tree. | rpm-ostree documentation

But there have been more than one occasion where someone has pointed out that a problem upstream (from my laptop) has created a situation where a restorecon or .autorelabel was needed.

Before that realization was made, some troubleshooting needs to be done. Without some record of it - what were the attrs set to before? And if the dirs / files in question were added from a layered package - (such that they do not exist in `/usr/etc` from the image) - now what?

It is just an important detail to consider. I prefer to have a record - just in case.

Hope that makes sense.

EDIT: guess I should have mentioned that this command (or equiv) preserves the SELinux attrs (just one of many ways to go about it):

```bash
cp --preserve=context /path/to/source/file /path/to/destination/   

```

---

<div class="post-metadata">

**Author:** ![locke496](https://yyz2.discourse-cdn.com/free1/user_avatar/universal-blue.discourse.group/locke496/32/8035_2.png) [@locke496](https://universal-blue.discourse.group/u/locke496)\
**Post date:** [March 4, 2026, 5:26pm UTC](https://universal-blue.discourse.group/t/how-do-you-back-up-and-restore-etc/7455/17 "2026-03-04T17:26:56Z")

</div>

I agree that in any case it is not bad to save the SELinux contexts.
